XML Input Stage Question

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
ashishm
Premium Member
Premium Member
Posts: 37
Joined: Thu Jun 16, 2011 8:12 am
Location: india

XML Input Stage Question

Post by ashishm »

Hi,

I'm trying to read an xml document which has multiple lines of xml. Each line is an xml document. In the XMl Source tab of Input link properties of XML Input Stage, I specify the column as file path, and create such a file which has the XML document file path.

Here is my problem.

If the XML document only has one line which mean one XML record, then I can extract the info. But if it two lines, which means there are two XMl records, then I'm not able to extract both records. Can anyone help me on this? thanks
nani1974
Premium Member
Premium Member
Posts: 52
Joined: Fri Aug 31, 2007 10:59 am

Post by nani1974 »

Hi,
how you read the XML file....before XML input stage...you should read the file as single LongVarChar field and then pass on to XML Input stage..there load the XML metadata in Output..Columns.. of the stage.
Regards,
Kumar.V
ashishm
Premium Member
Premium Member
Posts: 37
Joined: Thu Jun 16, 2011 8:12 am
Location: india

Post by ashishm »

Hi,

There is a Sequential File stage before the XML Input Stage, which reads a file that only contains the file path of the XML document. when it comes to the XML Input stage, I specify that column from the link of that Sequential File Stage as a URL/File path. That's how I can extract one XML record from that XML document. The scenario is this XML document has one XML record per line, as it was created by an XML Output Stage using the Output mode of single row.

My problem here is if that XMl document has two or more lines, how can I extract each line into one row.


Thank you.
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

I use a combination of External Source stage to provide the name of the xml file, then use that file name in an XML Input stage to start reading it. Since it was my very first XML job, I kept it simple, using Unix ls to grab the file name. If you have a file of file names inside of it, I believe you could use Unix cat instead, which just reads each line in the file you name.

Other have more experience with this than I do, so you should get further advice. In the meantime, it can't hurt to experiement.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Post Reply