XML : XSLT add a parent with ascending numbers and grouping with attribute

I have a bit of XML which I need to add a parent node to i.e. node1, node2, node3 etc. This I then need to also group with other nodes:

Original XML:

  <parentnode>  <childnode attribute="option.a.b.1">  </childnode>  <childnode attribute="option.a.b.2">  </childnode>  <childnode attribute="option.a.b.1">  </childnode>  <childnode attribute="option.a.b.2">  </childnode>  <childnode attribute="option.a.b.3">  </childnode>  <childnode attribute="option.a.b.1">  </childnode>  <childnode attribute="option.a.b.2">  </childnode>  </parentnode>    

Desired XML:

  <parentnode>  <row0>  <childnode attribute="option.a.b.1">  </childnode>  <childnode attribute="option.a.b.2">  </childnode>  </row0>  <row1>  <childnode attribute="option.a.b.1">  </childnode>  <childnode attribute="option.a.b.2">  </childnode>  <childnode attribute="option.a.b.3">  </childnode>  </row1>  <row2>  <childnode attribute="option.a.b.1">  </childnode>  <childnode attribute="option.a.b.2">  </childnode>  </row2>  </parentnode>    

option.a.b.* the * could be any number I just need it to start a new row every time option.a.b.1 appears. I'm not even sure if this is this possible in XSLT?

No comments:

Post a Comment