Hackday 9 - REXX, Java and XML
MartinPacker 11000094DH Comments (2) Visits (11826)
I've written about Hackday in the past. See My HackDay 6 Project - Mashing Up RMF, My HackDay 5 Project - z/OS System Logger Analysis and Hackday4 and Referer URLs (though I don't know why I didn't write about Hackday 7 or Hackday 8).
So, this year I participated in Hackday 9 (last Friday). My entry follows on from this recent blog post: BPXWUNIX - z/OS' Best Kept Secret?. Graham Harris, in his comment, mentions using java to process XML (albeit with issues with the XML generated by RMF, caused by the 2048 byte record limit of BPWUNIX). I'd been thinking along similar lines, though not RMF output specifically.
So my entry has at its core a java program that uses standard functionality to process XML. In particular I pass a filename and an XPath expression in to the java program and it returns the results of evaluating the expression. I intend it as a sample, rather than a really useful program - but I think it COULD be used.
I call the java program from REXX using BPXWUNIX. There is a wrinkle here. I'd not realised it before but you can pass in environment variables. Here's the REXX:
/* REXX */ /* Set up environment - else java executable can't be found */ env.0=1 env.
Apart from the "env" lines at the top (and the extra parameter to BPXWUNIX) and the java command this is exactly the same as code as in BPXWUNIX - z/OS' Best Kept Secret? and so needs no explanation.
Here's the XML file we're processing, so the XPath expression makes sense.
<?xml version="1.0"?> <inventory> <book year="2000"> <title>Snow Crash</title> <author>Neal Stephenson</author> <pub
In the XPath expression we look for the text in the title element of each of the book elements whose author element's value is "Neal Stephenson". (I got this XML and much besides, by the way, from The Java XPath API - Querying XML from Java programs. The result of evaluating the expression is:
1 Snow Crash
and this is because only two of the book elements match the [author="Neal Stephenson] condition.
The java to drive this is:
import java.io.*; import org.w3c.dom.*; import java
This is also largely described here.
So you have the sample REXX, java and XML to play with. A couple of things I would note:
One final thing: If you search in my blog you'll see I mention XPath in Workload Manager Policy in XML Format - Part I