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
How to write XML tags which occur more than 1 time
Moderators: chulett, rschirm, roy
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.
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.
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.
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.
xml writer output
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.
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.