I have following problem. I worked two days on a solution but I cannot find one.
I have a list with uncommon level-attribute (lists are only represented with margins in GDocs) and I want to re-level (sort) the nodes without restructuring the XML.
My input:
<lists>
<list margin="10">1</list>
<list margin="15">2</list>
<somethingelse/>
<list margin="33">3</list>
<list margin="72">4</list>
<list margin="15">5</list>
<list margin="64">6</list>
<list margin="72">7</list>
</lists>
This output would be ok:
<lists>
<list level="1">1</list>
<list level="2">2</list>
<somethingelse/>
<list level="1">3</list>
<list level="3">4</list>
<list level="1">5</list>
<list level="2">6</list>
<list level="3">7</list>
</lists>
My desired output (level difference between two nodes should only be 1)
<lists>
<list level="1">1</list>
<list level="2">2</list>
<somethingelse/>
<list level="1">3</list>
<list level="2">4</list>
<list level="1">5</list>
<list level="2">6</list>
<list level="3">7</list>
</lists>
Is this also possible to do with XSLT 1.0 ?
It seems I answer my question myself. Here is the solution. Keep in mind that the level difference between two lists will be maximum +-1.