I’m trying to find a solution to the following problem.
I’m developing XSLT transformation (which is now about 40KB big) that is transforming quite complex XMLs into a quite simple structure which would like this:
<Records>
<Record key="XX">
</Record>
<Record key="XX1">
</Record>
<Record key="XX2">
</Record>
<Record key="XX3">
</Record>
</Records>
I would like to have this output XML sorted according to Records/Record/@key values.
The problem is that my XSLT produces this output unsorted and due to its complexity I am unable to sort it there.
Is it possible to apply xsl:sort on the output XML? I know that I can prepare another XSLT transform, but in my case that’s not the solution, as I’m limited to only one XSLT.. Please, help!…
Yes, multipass processing is possible, and especially in XSLT 2.0 you don’t even need to apply an
xxx:node-set()extension on the result, because the infamous RTF type does no longer exist:When this transformation is performed on any XML document (not used/ignored), the wanted, correct, sorted result is produced:
In XSLT 1.0 it is almost the same with the additional conversion of the result from RTF type to a normal tree: