I have a following XML code:
<module>
<component>
<output>
<output-test>
<exclude-output/>
<orderEntry type="specific"/>
<orderEntry type="other"/>
<orderEntry type="module" module-name="module1"/>
<orderEntry type="module" module-name="module3"/>
<orderEntry type="module" module-name="module2"/>
<orderEntry type="library" name="library1"/>
<orderEntry type="library" name="library3"/>
<orderEntry type="module" module-name="module4"/>
<orderEntry type="library" name="library2"/>
</component>
</module>
I would like to have the output:
<module>
<component>
<output>
<output-test>
<exclude-output/>
<orderEntry type="specific"/>
<orderEntry type="other"/>
<orderEntry type="module" module-name="module1"/>
<orderEntry type="module" module-name="module2"/>
<orderEntry type="module" module-name="module3"/>
<orderEntry type="module" module-name="module4"/>
<orderEntry type="library" name="library1"/>
<orderEntry type="library" name="library2"/>
<orderEntry type="library" name="library3"/>
</component>
</module>
I am not entirely sure if this meets your requirements, but you could explicitly select the ones you want to come first in a separate
xsl:apply-templates, then select the others with a sort on theirtypeattributeLooking at the current expected output, it seems all the
typeattributes are in descending order, so you could simplify it to thisTry this XSLT
Note that, if you actually wanted to sort on
typeattribute that were not in alphabetical order, you could do something like this: