MQ Connector Stage to Process XML Files

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Naren12345babu
Premium Member
Premium Member
Posts: 76
Joined: Wed Jan 06, 2016 9:40 am
Location: Bangalore

MQ Connector Stage to Process XML Files

Post 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..
Thanks
Naren Babu Ch
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

'XML file structure' IS a single string. Pass it along to your XML parsing stage of choice.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Naren12345babu
Premium Member
Premium Member
Posts: 76
Joined: Wed Jan 06, 2016 9:40 am
Location: Bangalore

Post 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 ?
Thanks
Naren Babu Ch
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Naren12345babu
Premium Member
Premium Member
Posts: 76
Joined: Wed Jan 06, 2016 9:40 am
Location: Bangalore

Post 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?
Thanks
Naren Babu Ch
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post 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
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And the short answer to the question you asked me is: no. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Naren12345babu
Premium Member
Premium Member
Posts: 76
Joined: Wed Jan 06, 2016 9:40 am
Location: Bangalore

Post by Naren12345babu »

Okay guys. I will try the approach. Thank you for the inputs. Will let you know once done.
Thanks
Naren Babu Ch
Post Reply