Grouping parent node based on child elements values and sequence number.
Posted
by
Mahir
on Stack Overflow
See other posts from Stack Overflow
or by Mahir
Published on 2011-01-12T15:49:39Z
Indexed on
2011/01/12
15:54 UTC
Read the original article
Hit count: 161
xslt
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
© Stack Overflow or respective owner