Multiple XML Transactions into One Single File

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
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Multiple XML Transactions into One Single File

Post by pavankvk »

Hi

i have to do something like this. i need to create an Unformatted XML for each row in the database and have all of them in one big sequential file.

I used XMLOutput stage to create one single XML per row. but the problem is XMLOutput stage creates one XML file on the file system per row. As we can have millions of rows, its not possible. Instead of capturing that output in a file, i need it as a row in a file.

<?xml version="1.0" encoding="UTF-8"?><BusNameGrp><BusName>DUNKIN DONUTS</BusName><BusState>CT</BusState></BusNameGrp>
<?xml version="1.0" encoding="UTF-8"?><BusNameGrp><BusName>JACK DONUTS</BusName><BusState>C0</BusState></BusNameGrp>
<?xml version="1.0" encoding="UTF-8"?><BusNameGrp><BusName>KRISPY CREME DONUTS</BusName><BusState>CA</BusState></BusNameGrp>

Currently each XML transaction is in a separate file. i need all of them in one single file.

Any ideas?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Select the 'Aggregate all rows' Output mode on the Transformation Settings tab.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Post by pavankvk »

chulett wrote:Select the 'Aggregate all rows' Output mode on the Transformation Settings tab. ...
Craig

that is not what i want..i know that aggregate option.but that is not what i want.

if you observe the XML lines, each of them is a individual XML and there is no key value for any element so that group of elements fall under one parent element. if i use an id attribute for the TransGrp element,i can get them in one XML.But my requirement is specifically with out using that..i will just generate one complete XML file for each record..and instead of writing each xml file to the file system, i want them to be written as rows in a file.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You've completely lost me. :?

If you are saying the current output is correct but it all needs to be in one sequential (non XML) file - have you tried an Output link from the XML Output stage to a Sequential File stage?
-craig

"You can never have too many knives" -- Logan Nine Fingers
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Post by pavankvk »

chulett wrote:You've completely lost me. :?

If you are saying the current output is correct but it all needs to be in one sequential (non XML) file - have you tried an Output link from the XML Output stage to a Sequential File stage?
Yes i did. When i have an output link from the xmloutput stage to a sequential file stage, the sequential file gets the column information of the XMLOutput stage.It contains the information of the elements that i used to form the XML.say the length of my element is 120 bytes the sequential stage also has this information.if i have 10 elements in the xmloutput stage all those 10 elements appear in the sequential file stage...the output will be truncated according to the length of each column.

it doesnt work.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I would disagree that "it doesn't work"... more correct to say you haven't gotten it working. Yet.

I suggest setting up your sequential file with one large varchar field to hold the entire record, then just use a forward slash "/" as the XPath expression. That should get you much closer.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Post by pavankvk »

chulett wrote:I would disagree that "it doesn't work"... more correct to say you haven't gotten it working. Yet.

I suggest setting up your sequential file with one large varchar field to hold the entire record, then just use a forward slash "/" as the XPath expression. That should get you much closer.
here are my xptah expressions in the xmloutput.

/IDMIdentTran/BusNameGrp/BusName/text()
/IDMIdentTran/BusNameGrp/BusState/text()

How should i map them into one single Xpath expression so that i can get the complete XML in one sequential file?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As noted - one field with a single forward slash as the XPath expression.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Post by pavankvk »

chulett wrote:As noted - one field with a single forward slash as the XPath expression. ...
Thanks a lot craig. it worked.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Cool. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Post by pavankvk »

chulett wrote:Cool. :D ...
Craig

when i am trying to produce my file with real data...for some of the XMLs generated, the tags are lost or misspelt or truncated and ill formed...when i produced a data of 1800 records, i had 20 ill formed XMLs in them.. The same data looks perfectly ok in flat files. Other 1780 records are fine..I dont understand whats causing this behavior. Is it a bug in the XMLOutput stage?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not any behaviour I've ever seen. Probably time to call support.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply