Looking for pointers (examples preferably) on parsing xml in NetRexx.
The task is formatting MQFTE transfer log msgs. This was done historically by a set of java pgms whose origin I'm unfamiliar with. Following one upgrade several years ago of the command-and-coordinator qmgr from MQ v7.5 to v8.0, the xml parser ('log reporter') was throwing errors on logger msgs produced by FTE agents that were also upgraded. My java cluelessness (& other resource constrictions) resulted in me cobbling together an alternate parser using shell script examples freely available. I struggled to comprehend how the java solution functioned, and my attempts at inserting debug stmts just broke it - throwing me at the quick-n-dirty shell script option. You know how deadlines loom. However, while it works & at least I can understand it, it's SLOW. So, the goal is to return to a better performing java based MQFTE log reporter by means of NetRexx. I've often thought there must be a NetRexx xml parser solution out there somewhere. Does such a tool exist? Peter BTW, MQ upgrades to v9.1 are well under way. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 07.06.2021 15:14, Peter Sharp wrote: Looking for pointers (examples preferably) on parsing xml in NetRexx. The task is formatting MQFTE transfer log msgs. This was done historically by a set of java pgms whose origin I'm unfamiliar with.
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
On 07.06.2021 15:14, Peter Sharp wrote:
Looking for pointers (examples preferably) on parsing xml in NetRexx. Not sure this will help you, but may enable you to take advantage of Java-SAX and/or Java-DOM solutions from NetRexx, by rewriting/recoding the BSF4ooRexx examples in NetRexx. If you do, I would be very interested in them of course! :)
If you have ooRexx and install BSF4ooRexx you would find the ooRexx samples to transcribe to NetRexx in the "samples/SAX" and "samples/DOM" subdirectories. --- Again, IMHO, the fastest/easiest route is probably via SAX. HTH, ---rony [1] "Simple API for XML":
<https://en.wikipedia.org/wiki/Simple_API_for_XML> _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 7/6/21 11:45 pm, Rony G. Flatscher wrote: On 07.06.2021 15:14, Peter Sharp wrote: Looking for pointers (examples preferably) on parsing xml in NetRexx. The task is formatting MQFTE transfer log msgs. This was done historically by a set of
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
On 7/6/21 11:45 pm, Rony G. Flatscher
wrote:
On 07.06.2021 15:14, Peter Sharp wrote: Looking for pointers (examples preferably) on parsing xml in NetRexx. The task is formatting MQFTE transfer log msgs. This was done historically by a set of java pgms whose origin I'm unfamiliar with. ZjQcmQRYFpfptBannerStart Rony, Thanks for the pointers. Unfortunately, a bsf4ooRexx install didn't yield the promised samples (this time). Have I missed something? Below is the result of searches for the samples, SAX & DOM dirs, plus a search for any *.rxj files under the bsf4ooRexx install dir. -------------------------------- [psharp@fedora NetRexx]$ find bsf4ooRexx -name samples _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 07.06.2021 16:56, Peter Sharp wrote: On 7/6/21 11:45 pm, Rony G. Flatscher wrote: On 07.06.2021 15:14, Peter Sharp wrote: Looking for pointers (examples preferably) on parsing xml in NetRexx. The task is formatting MQFTE transfer log msgs.
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
On 07.06.2021 16:56, Peter Sharp wrote:
On 7/6/21 11:45 pm, Rony G. Flatscher wrote: On 07.06.2021 15:14, Peter Sharp wrote: Looking for pointers (examples preferably) on parsing xml in NetRexx. The task is formatting MQFTE transfer log msgs. This was done historically by a set of ZjQcmQRYFpfptBannerStart Peter, you seem to have fetched the BSF4ooRexx testunits. Given
your last output (path to test.rxj), the samples directory should
be in "bsf4ooRexx/BSF4ooRexx_testUnits/samples" on your machine. If you had installed BSF4ooRexx on a Linux machine, it should be
in "/opt/BSF4ooRexx/samples". Alternatively, you could look them up starting out pointing your
browser at:
<https://sourceforge.net/p/bsf4oorexx/code/HEAD/tree/trunk/samples/>. HTH, ---rony
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by Peter Sharp-2
Follow along with NetRexx
A Java to NetRexx conversion that could be done better Their stuff; Their rules https://howtodoinjava.com/java/xml/sax-parser-read-xml-example/ Download the conversion https://github.com/agrellum/NetRexx-Samples/raw/master/SAXNRX.tar.gz unpack cd to it nrc *nrx java TestSaxParser _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Thanks Jason! As expected, the nrx solution is so much more elegant than
java :-) Seeing the flavours of xml parsing listed there, what I actually need is an nrx version of the convert-xml-to-properties function. Should keep me busy for a while. Peter On 8/6/21 3:06 am, Jason Martin wrote: > Follow along with NetRexx > > A Java to NetRexx conversion that could be done better > > Their stuff; Their rules > > https://howtodoinjava.com/java/xml/sax-parser-read-xml-example/ > Download the conversion > > https://github.com/agrellum/NetRexx-Samples/raw/master/SAXNRX.tar.gz > unpack > > cd to it > > nrc *nrx > > java TestSaxParser Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
--package com.howtodoinjava.demo
import java.io.FileInputStream import java.io.FileOutputStream import java.io.IOException import java.io.InputStream import java.io.OutputStream import java.util.InvalidPropertiesFormatException import java.util.Properties class XMLToProperties public method main(args=String[]) static signals InvalidPropertiesFormatException,IOException --outPropertiesFile=String outPropertiesFile="./application.properties" --inXmlFile=String inXmlFile="applicationProperties.xml" --inStream=InputStream inStream=FileInputStream(inXmlFile) --outStream=OutputStream outStream=FileOutputStream(outPropertiesFile) --props=Properties props=Properties() props.loadFromXML(inStream) props.store(outStream,"Converted from applicationProperties.xml") --System.out.println(props.get("input.dir")) say props.get("input.dir") _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Second verse same as the first. tweak args=String[], types and
directories. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by Jason Martin
Well, I have the beginnings of an xml parser, thanks to Rony & Jason!
Copied this input from somewhere in the samples: [psharp@fedora SAXNRX]$ cat ./MyProps.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd "> <properties> <comment>application.properties</comment> <entry key="input.dir">c:/temp/input</entry> <entry key="spring.batch.job.enabled">false</entry> <entry key="spring.main.banner-mode">off</entry> </properties> [psharp@fedora SAXNRX]$ Clean compile (finally!): [psharp@fedora SAXNRX]$ nrc xmlToProps.nrx NetRexx portable processor 4.01-GA build 573-20210320-2000 Copyright (c) RexxLA, 2011,2021. All rights reserved. Parts Copyright (c) IBM Corporation, 1995,2008. Program xmlToProps.nrx === class xmlToProps === function main(String[]) signals IOException,InvalidPropertiesFormatException Compilation of 'xmlToProps.nrx' successful [psharp@fedora SAXNRX]$ Useful execution: [psharp@fedora SAXNRX]$ java xmlToProps ./MyProps.xml #XML Properties file: ./MyProps.xml spring.batch.job.enabled=false input.dir=c:/temp/input spring.main.banner-mode=off [psharp@fedora SAXNRX]$ And finally, a rudimentary xml properties parser: [psharp@fedora SAXNRX]$ cat xmlToProps.nrx --package com.howtodoinnrx.xml.sax import java.io.File import java.io.FileInputStream import java.io.FileNotFoundException import java.util.Properties class xmlToProps public method main(args=String[]) static signals FileNotFoundException say '#XML Properties file:' (string args[0]) xmlFile=File(args[0]) props=Properties() props.loadFromXML(FileInputStream(xmlFile)) keyList = props.propertyNames() loop while keyList.hasMoreElements() key = keyList.nextElement() value = props.getProperty(String key) say key"="value end [psharp@fedora SAXNRX]$ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |