Hi!
I have to do this transformation:
Source:
Code:
<root>
<Invoice>
<Invoice_Num>0</Invoice_Num>
<InvoiceData1>aa</InvoiceData1>
<InvoiceData2>bb</InvoiceData2>
</Invoice>
<Delivery>
<Invoice_Num></Invoice_Num>
<Delivery_Num>1</Delivery_Num>
<DelData1>aa</DelData1>
<DelData2>dd</DelData2>
</Delivery>
<Line>
<Delivery_Num></Delivery_Num>
<LineData1>1234</LineData1>
<LineData2>4321</LineData2>
</Line>
</root>
Target:
Code:
<root>
<Invoice>
<Invoice_Num>0</Invoice_Num>
<InvoiceData1>11</InvoiceData1>
<InvoiceData2>22</InvoiceData2>
</Invoice>
<Delivery>
<Invoice_Num>0</Invoice_Num>
<Delivery_Num>1</Delivery_Num>
<DelData1>aa</DelData1>
<DelData2>dd</DelData2>
</Delivery>
<Line>
<Delivery_Num>1</Delivery_Num>
<LineData1>1234</LineData1>
<LineData2>4321</LineData2>
</Line>
</root>
As you can see each "Delivery" must get the number of previous "Invoice", and each "Line" the number of previous "Delivery".
Each of nodes occures from 0-n times (except "Invoice", it's always occurs at least one time).
As I need to use XSLT 1.0(I' am building the mapping for SAP XI) the only way to do this kind of transformation is using the recursion, am I right?
Actually I can't understand the logic how the recursive function must work in this case, what elements I must pass (Invoice? Delivery? Line?)
My be I need three different recursive functions for each type of node? Any help would be greatly welcomed!