Page 1 of 1

MQ Connector Stage to Process XML Files

Posted: Fri Jan 29, 2016 7:32 am
by Naren12345babu
Hi,

I am using a MQ Connector stage to pull XML messages from MQ.

Each XML File is present as a single message in MQ. Now I want to read this through MQ COnnector and then read it as a XML File format. How can I do this.

Currently, when I read messages, it gives me everything in a single string , rather than in XML file structure..

Posted: Fri Jan 29, 2016 8:48 am
by chulett
'XML file structure' IS a single string. Pass it along to your XML parsing stage of choice.

Posted: Fri Jan 29, 2016 9:14 am
by Naren12345babu
Hi chulett,

thank you for solution. but once I read XML file as a string from MQ Connector and use XML Output stage or XML input stage to read this string, how can I make sure metadata in XML parsing stage and MQ Connector stage are same ?

If I read file as a single string, then MQ connector will have a single column. where as the immediate XML Parsing stage , I have to add multiple columns as per the XML file. How is this possible ?

Posted: Fri Jan 29, 2016 10:34 am
by chulett
Guessing you've not worked with XML before? High level:

You need to generate the metadata from either a sample of the file itself or from an "xsd" you received from the source. That will generate the columns and "XPath Expressions" needed to parse the XML and you can then import that into your stage so it knows what to do.

XML Input stage, btw. XML Output is for creating XML. Or there's the new XML stage but it will be a little daunting for someone new to the XML experience.

Posted: Fri Jan 29, 2016 1:37 pm
by Naren12345babu
Hi Craig,

Yes, I am working on XML stages first time. Do I need to import the XSD to the MQ connector as well as XML Input stage?

Posted: Fri Jan 29, 2016 1:53 pm
by eostic
The MQ Connector just delivers messages --- and at best, a single column....just a big chunk of text. Deliver that to your xmlInput Stage or the Hierarchical Stage as a single column... (Craig is correct --- start with the xmlInput Stage if you have never done xml before).

And LONG before you try to combine them as outlined above, work with them separately..... (a) Get ONE messages read from the message queue and into a sequential file using the Sequential Stage. One column on the input link, and use NONE and NONE for the quote character and the delimiter. Make sure you get a single nice clean row of data, with a whole document that represents your original whole message. (b). Then learn how to parse THAT sequential file with the xmlInput Stage, parsing it accordingly after importing the metadata for the xml document file you just produced. Read hundreds of other posts to this forum....look thru the doc. There are lots of places to get resources on how to make that happen. (c) combine the two.

Ernie

Posted: Fri Jan 29, 2016 2:22 pm
by chulett
And the short answer to the question you asked me is: no. :wink:

Posted: Fri Jan 29, 2016 6:08 pm
by Naren12345babu
Okay guys. I will try the approach. Thank you for the inputs. Will let you know once done.