XML Output - Repetitive Tags

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
junior55
Participant
Posts: 1
Joined: Mon Dec 04, 2017 11:26 am
Location: Albania

XML Output - Repetitive Tags

Post by junior55 »

First of hi to all the members here since this is my 1st post.
While learning dstage stuff I have been visiting this site very often and always managed to find the answers I was looking for, except this time :(.
I hope I am not repetitive in my question as I saw many similar ones but couldn't make it work for my case:

I have the following data in the xml input file that I need to load: ( I am pasting only 1 group of tags...
<?xml version="1.0" encoding="UTF-8" ?>
<envelope>
<invoice>
<POID>0.0.0.1 /bill 36987435346 4</POID>
<INV_PAGE elem="0">
<PAGE_TYPE>VAT INVOICE</PAGE_TYPE>
<CHARGES elem="0">
<VAT_PERCENT>TAX20</VAT_PERCENT>
<NON_USAGE>500</NON_USAGE>
<USAGE>0</USAGE>
<MONTHLY_DISCOUNT>0</MONTHLY_DISCOUNT>
<TOTAL>500</TOTAL>
</CHARGES>
<TAXES elem="0">
<TAX_RATE>TAX20</TAX_RATE>
<TAX>100</TAX>
<TAX_BASE>500</TAX_BASE>
</TAXES>

<CHARGES elem="1">
<VAT_PERCENT>TAXNN</VAT_PERCENT>
<NON_USAGE>0</NON_USAGE>
<USAGE>100</USAGE>
<MONTHLY_DISCOUNT>0</MONTHLY_DISCOUNT>
<TOTAL>100</TOTAL>
</CHARGES>
<TAXES elem="1">
<TAX_RATE>TAXNN</TAX_RATE>
<TAX>0</TAX>
<TAX_BASE>100</TAX_BASE>
</TAXES>
<NET_TOTAL>600</NET_TOTAL>
<TOTAL_AMOUNT>700</TOTAL_AMOUNT>
<TOTAL_AMOUNT_DUE>699.998</TOTAL_AMOUNT_DUE>
</INV_PAGE>
<DELIVERY>paper</DELIVERY>
<PAGE_TYPE>CUSTOMER</PAGE_TYPE>

blablabla
<PAGE_TYPE>SUBSCRIBER</PAGE_TYPE>
blablabla



My job used to run fine until the bolded part was added in the source.
The initial trigger element before the bolded part was added was: /envelope/invoice/INV_PAGE (since INV_PAGE was the lowest level repetitive tag) I used to output different PAGE_TYPE tags in different output links.

What I need now is to get the bolded part from the PAGE_TYPE = VAT INVOICE but I cant make it to produce 2 different lines (with each repetitive tag of the bolded and italic part)
With the old configuration I receive now the following output:

"0.0.0.1 /bill 36987435346 4","TAXNN","0","100","0","100","TAXNN","0","100","600","700","699.998","VAT INVOICE","217054152", (it seems like only TAXNN is being exported and I don't even understand why it is picking elem=1 and not elem=0 for example)

Since the bolded part is added, I decided to play with the trigger element and chose a lower level (CHARGES or TAXES) but in neither case I receive what I want:
What I get as output after changing trigger to /envelope/invoice/TAXES or /envelope/invoice/CHARGES is the following:
What is it:
"0.0.0.1 /bill 36987435346 4","TAX20","500","0","0","500",,,,,,,"VAT INVOICE","217054152",
"0.0.0.1 /bill 36987435346 4","TAXNN","0","100","0","100","TAX20","100","500",,,,"VAT INVOICE","217054152",

While what I need is this :
What i need:
"0.0.0.1 /bill 36987435346 4","TAX20","500","0","0","500",TAX20,100,500,600,700,699.998,"VAT INVOICE","217054152",
"0.0.0.1 /bill 36987435346 4","TAXNN","0","100","0","100","TAXNN","0","100",600,700,699.998,"VAT INVOICE","217054152",

So It looks like after going in a lower level I can produce the 2 rows that I need (although still not correctly as data seems to be merged somehow) but also losing the data of the last 3 tags <NET_TOTAL> , <TOTAL_AMOUNT> and <TOTAL_AMOUNT_DUE>

I hope my question is clear and has enough data. If not please let me know.

Your help Is really welcomed
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome! Just want to perform a quick sanity check. :wink:

Is this truly a 7.x Server job that you are having the issue with?
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Welcome on board! For each output link, you decide which repeating node dictates the number of rows produced. When you have parallel repeating nodes (in this example, quick glance shows taxes and charges both repeat on their own), then you need a separate link for each. If these are somehow related to each other, there are some tricks you could play with xslt, but the best way to approach this is probably to "get the data out, and then relate it together downstream. If the two repeating nodes are related by instance, you could set up counters, for example, and match up the "first instance" of charge with the "first instance of taxes", etc. etc. etc. Be sure to understand what the behavior should be if one of them repeats (say) 9 times and the other one only 5.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply