How to reorder node elements such that they match an xsd:sequence order?

后端 未结 3 611
青春惊慌失措
青春惊慌失措 2021-01-25 13:16

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

3条回答
  •  囚心锁ツ
    2021-01-25 14:01

    You can manipulate XML directly in Java using the following packages:

    import org.w3c.dom.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    

    You'll need to put an XML parser such as saxon ( see http://saxon.sourceforge.net/ ) on your classpath

    You can manipulate the XML 'by hand', reading bits of the input document and creating the required output document or you can write an xslt style sheet and use it to transform the document straight from your Java code.

    Try here for a starting point:

    http://oreilly.com/catalog/javaxslt/chapter/ch05.html

提交回复
热议问题