Is there any way to reorder elements in a Node objects such that they match an xsd:sequence
order? I\'ve read through the docs for Node.normalize
, but
If you only have xs:sequence to worry about, and not choice/repetition, and so long as the schema isn't written to use lots of complex features like named model groups and substitution groups and wildcards, then it shouldn't be too difficult, at any rate if you use XSLT 2.0 or XQuery and forget about trying to code it in Java. If the variable $seq is an xs:sequence element, then the sort key for an element named $E is "count($x/xs:element[(@name|@ref)=$E]/preceding-sibling::*", so you can just plug this expression into an xsl:sort as
...
Probably needs a bit of finessing for namespaces or other things you might encounter, but you get the idea.