DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
Author Message
sansan



Group memberships:
Premium Members

Joined: 20 Jun 2003
Posts: 19

Points: 173

Post Posted: Mon Dec 29, 2003 1:03 am Reply with quote    Back to top    

DataStage® Release: 7x
Job Type: Server
OS: Windows
Hi,
I want to produce an XML file,but I faced one problem.I have tags which occurs 4 times (TotalPayments).
I don't how to write it in Xpath to occur 4 times in the output XML file.I tried to use (SaleRecord//TotalPayment/Subtotal)
but show me the error "the derivation rule is invalid". Currently, I'm using XML 2 pack.


Output Records look like this:
<SaleRecord>
<Din>123456</Din>
<SerialNo>1</SerialNo>
<TotalPayment>
<Subtotal>124</Subtotal>
<Balance>1234</Balance>
</TotalPayment>
<TotalPayment>
<Subtotal>156</Subtotal>
<Balance>1978</Balance>
</TotalPayment>
<TotalPayment>
<Subtotal>678</Subtotal>
<Balance>9999</Balance>
</TotalPayment>
<TotalPayment>
<Subtotal>563</Subtotal>
<Balance>4444</Balance>
</TotalPayment>
</SaleRecord>


Thanks a lot,
san san

_________________
cmueller
Participant

Group memberships:
Premium Members, DSXchange Team, Inner Circle

Joined: 23 Oct 2002
Posts: 46

Points: 134

Post Posted: Mon Dec 29, 2003 8:27 am Reply with quote    Back to top    

Pipe any non repeating data to a hashed file stage, using serialno for the key. Then pipe repeating tags to the an xmloutput stage, and then to another hashed file stage to which you will write the repeating tags as xml chunks and use the serialno as key. It may look like this
SerialNo:1
TotalPayment: <Subtotal>124</Subtotal><Balance>1234</Balance> <Subtotal>156</Subtotal><Balance>1978</Balance> <Subtotal>678</Subtotal><Balance>9999</Balance> <Subtotal>563</Subtotal><Balance>4444</Balance>

Then you can join both hashed files using the second as a lookup and pipe it all to an xmloutput stage.
Rate this response:  
Not yet rated
trobinson
Participant

Group memberships:
Heartland Usergroup

Joined: 11 Apr 2002
Posts: 208
Location: Saint Louis
Points: 1298

Post Posted: Mon Dec 29, 2003 8:34 am Reply with quote    Back to top    

I'm not sure what you are asking. Asusming you want Subtotals repeated 4 times within a TotalPayment within a Sale Record then;

Try /SaleRecord/TotalPayment/SubTotal/text() in the description of the XPATH and mark the column as the key column. Defining a column as key defines the column as a repeating group.
Rate this response:  
Not yet rated
sansan



Group memberships:
Premium Members

Joined: 20 Jun 2003
Posts: 19

Points: 173

Post Posted: Sun Jan 04, 2004 11:40 pm Reply with quote    Back to top    

Thanks you very much,cmueller.
I'm able to write the repeating tags to the xmloutput,but is there any other ways instead of using hash files? As I have over 10 millions records which saved in the hash files,and then it's comsuming a lot of spaces in DatastagServer.

_________________
Rate this response:  
Not yet rated
netboyks
Participant



Joined: 08 Mar 2003
Posts: 20

Points: 248

Post Posted: Tue Mar 02, 2004 12:35 pm Reply with quote    Back to top    

cmuller,
In your solution could you let me know how to handle a situation where I need the following output format. Please look at the last record. In summary I need to produce a closing tag (</Balance>) if there is no Balance value for the SubTotal.

TotalPayment: <Subtotal>124</Subtotal><Balance>1234</Balance> <Subtotal>156</Subtotal><Balance>1978</Balance> <Subtotal>678</Subtotal></Balance>

Thanks

Netboyks.

cmueller wrote:
Pipe any non repeating data to a hashed file stage, using serialno for the key. Then pipe repeating tags to the an xmloutput stage, and then to another hashed file stage to which you will write the repeating tags as xml chunks and use the serialno as key. It may look like this
SerialNo:1
TotalPayment: <Subtotal>124</Subtotal><Balance>1234</Balance> <Subtotal>156</Subtotal><Balance>1978</Balance> <Subtotal>678</Subtotal><Balance>9999</Balance> <Subtotal>563</Subtotal><Balance>4444</Balance>

Then you can join both hashed files using the second as a lookup and pipe it all to an xmloutput stage.
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours