I’m using javax.xml.transform.Transformer.transform() to convert one xml to another through an xsl stylesheet. I would like to programatically set the sorting of the first level of children, but am unsure how to go about it. I’ve checked out the docs, but I don’t understand which type of property/parameter to use and how to specify in sort:
<xsl:sort select="*need to get property or parameter to here*"/>
I am open to other ideas, but would rather not parse the xml result into a w3c document.
Edit:
To clarify I am looking to set the sort key and direction for the elements in a xsl:for-each tag via the Transformer API.
This stylesheet:
With this input:
Output:
Note: You could define
pSortingByparam to be any element name following specifications from your XSLT processor.Edit: I’m not a java expert, but I think you could do: