Problem solve Get help with specific problems with your technologies, process and projects.

Manual parsing techniques

Our group is going to create an XML interface between the Web and our mainframe. We are currently using CICS TS 1.3 and OS390 and are not yet to Enterprise COBOL V3. If at all possible we would like to receive the XML document on the mainframe and perform the parsing there rather than parse the message and then send it to the mainframe. I have been researching the SOAPS package but it lacks a parser.

One of our requirements is that whatever we use it must be within the IBM package that we already have. Is there an IBM parser that's available for our use at HUD?

I think you need to revisit the decision not to upgrade to Enterprise COBOL. The parsing built in function will ASSIST in the unraveling of XML-based information. However, that being said there is no reason why you cannot do all the data extraction yourself by good-old substringing techniques. But I give a strong warning about avoiding anything that repeats - this only complicates matters. You also have to accept that no checking on the XML flow itself will be done (it matches the DTD and is well formed -- so that does not occur).

What you do have to be careful about is writing code that can accept the variability of information. You have got especially to cope with the fact that white space is deemed to be irrelevant. On the plus side, you seem to have control of the Web pages yourself and so can define the format of the XML data (by which I mean you can ignore optimizations).

If you can get access to the Nordic Guide/Share Web site, there is an interesting presentation there (by me, naturally!) on the CICS SOAP SupportPac that goes into manual parsing techniques.

To give an example: If you have: ' data ' you have got to cope with ' data ' in your parsing routine, along with all other variants. Life is made a LOT easier if you insist on everything being in UPPERCASE.

So, proceed by knowing all the s that you can have and then proceed to extract each one in turn into a structure -- which you will have prefilled with defaults.

To access a flat data XML arrangement you will need to implement logic like:

scan for the < skip to the next non-blank extract up to the next blank or > --- this gives you the relevant KEY, and so you know what field you are processing skip to the next > (or stay put if the aforementioned > was located) skip to the next non-blank character -- if this is a < then the ITEM is empty extract up to the next < -- this gives you the VALUE for the KEY [If you were using Rexx, then this function could be done via : parse upper xmlflow . '<' key '>' value '<' . '>' xmlflow key = translate(strip(key,'B')) ; value = translate(strip(value,'B')) until xmlflow has all been processed]

You then need to get rid of leading and trailing blanks from the VALUE, check the length of it (so it fits in the structure), validate it is all numeric (if needed) and do general formatting checks. Once you think the VALUE is acceptable then you can use the KEY (via some sort of Select statement) and stick it into the relevant bit of the Structure.

If you are required to cope with mixed case KEYs or VALUEs then the easiest way is to copy the XML flow into another area, and do the extraction on the copy that has been folded to Uppercase -- you want to save the Position & Length of the VALUE for possessing.

Things are obviously more complicated than this if you choose to use a nested arrangement like data but this design should cope with a flat data data arrangement.

Robert Harris
CICS Technical Strategist -- CICS expert at Search390.com

Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our .VO7aaqqaAFk.0@/search390>discussion forums.

Dig Deeper on IBM system z and mainframe systems

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.