Your problem translates to this: you have an XSM file that doesn't match the schema and you want to transform it to something that's valid.
With XSOM, you can read the structure in the XSD and perhaps analyze the XML but it still would need additional mapping from the invalid form to the valid form. The use of a stylesheet would be much easier, because you would walk through the XML, using XPath nodes to handle the elements in the proper order. With an XML where you want apples before pears, the stylesheet would first copy the apple node (/Fruit/Apple) before it copies the pear node. That way, no matter of the order in the old file, they would be in the correct order in the new file.
What you could do with XSOM is to read the XSD and generate the stylesheet that will re-order the data. Then transform the XML using that stylesheet. once XSOM has generated a stylesheet for the XSD, you can just re-use the stylesheet until the XSD is modified or another XSD is needed.
Of course, you could use XSOM to copy nodes immediately in the right order. But since this means your code has to walk itself through all nodes and child nodes, it might take some time to process to finish. A stylesheet would do the same, but the transformer will be able to process it all faster. It can work directly on the data while the Java code would have to get/set every node through the XMLDocument properties.
When I think about this, I wonder if this has been done before already. It would be very generic and would be able to handle almost every XSD/XML.
Let's see... Using "//xsd:element/@name" you would get all element names in the schema. Every unique name would need to be translated to a template. Within these templates, you would need to process the child nodes of the specific element, which is slightly more complex to get. Elements can have a reference, which you would need to follow. Otherwise, get all child xsd:element nodes it.
OK, cool, we're both on the same page now :) I agree that a XSL transform would re-arrange my document more efficiently than manually poking around in the DOM, but the initial problem of using the XSOM API to find out what the order should be remains, regardless of the mechanism I use to perform the re-ordering itself.
I suddenly wonder if it isn't possible to use a stylesheet to transform an XSD into an XML-copying stylesheet. Would make an interesting cross-platform solution. If you're already familiar with XSD's and XSLT's then this might be easier than having to learn more about XSOM.
I dunno, schemas can be fearsomely complex, especially the ones I'm working with.... extended types, substitution groups, all that stuff. Scary.