I have multiple Rows data in my XML like this -
<ROW TYPE="SPECIFICATION" ID="1">
<R1>English1</R1>
</ROW>
<ROW TYPE="SPECIFICATION" ID="1">
<R1>Maths1</R1>
</ROW>
<ROW TYPE="TOTAL" ID="1">
<R1>Code1</R1>
</ROW>
<ROW TYPE="SPECIFICATION" ID="2">
<R1>English2</R1>
</ROW>
<ROW TYPE="SPECIFICATION" ID="2">
<R1>Maths2</R1>
</ROW>
<ROW TYPE="TOTAL" ID="2">
<R1>Code2</R1>
</ROW>
I want my Output to be displayed in Image like that this ROW data works in a for-each loop. And the requirement is that ROW TYPE="TOTAL" ID="1" should be displayed first then its ROW TYPE="SPECIFICATION" data. Moving further in loop again, ROW TYPE="TOTAL" ID="2" should be displayed first then its ROW TYPE="SPECIFICATION" data.
Basically it should come like this -
Code1
English1
Maths1
Code2
English2
Maths2
The XSLT code works for sequence as for-2each loop works. But I need to shift the TOTAL row first for that ID. Please suggest logic for this.
This transformation:
when applied on the provided XML (wrapped into a single top element to be made a well-formed XML document):
produces the wanted result (in which the wanted elements are re-ordered: