Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB Namespace Order

Tags:

java

xml

jaxb

Is it possible to control the order of namespaces in documents generated via JAXB? I know, it is not relevant to XML standards, but somehow we need to generate namespace declarations in specific order? For example, currently we have generated

<rootelement a="http://www.example.com/xom" b="http://www.example.com/crops">
..
</rootelement>

But I need:

<rootelement b="http://www.example.com/crops" a="http://www.example.com/xom">
..
</rootelement>
like image 810
anergy Avatar asked Oct 20 '10 14:10

anergy


1 Answers

JAXB does not directly supports that, but you can marshal your object to ContentHandler, XMLStreamWriter or XMLEventWriter and take care of the namespace and attribute ordering in there.

like image 78
Eugene Kuleshov Avatar answered Oct 14 '22 00:10

Eugene Kuleshov