Grouping parent node based on child elements values and sequence number.
- by Mahir
Hi,
I need to transform XML using xslt.
Logic:
Split the parent if the parent having different child address and append the sequence number with parent name. Also need line number for the child.
Here we may have number of parent nodes and each parent node may have more number of child nodes.
I have tried numerous ways to achieve this and I am stuck with generating sequence number in the foreach. So can any one try and give a solution for this.
Source XML as below:
P1
CName1
Address1
CName2
Address2
CName3
Address1
P2
CName1
Address1
The target XML should as below:
P1_1
CName1
Address1
1
CName2
Address2
2
CName3
Address1
P1_2
1
CName2
Address2
P2_1
1
CName1
Address1