JAXB appending unneeded namespace declarations to tags

Posted by jb on Stack Overflow See other posts from Stack Overflow or by jb
Published on 2009-11-04T13:00:31Z Indexed on 2010/05/08 15:18 UTC
Read the original article Hit count: 278

Filed under:
|
|
|
|

I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded namespace declarations:

   <ns2:auth xmlns:ns2="urn:ietf:params:xml:ns:ilf-auth" 
   xmlns:ns4="ilf:iq:experiment:power" xmlns:ns3="ilf:iq:experiment:init" 
   xmlns:ns5="ilf:iq:experiment:values" xmlns:ns6="ilf:iq:experiment:result" 
   xmlns:ns7="ilf:iq:experiment:stop" xmlns:ns8="ilf:iq:experiment:end">
   compton@ilf</ns2:auth>

instead of:

   <ns:auth xmlns:ns="urn:ietf:params:xml:ns:ilf-auth>compton@ilf</ns:auth>

Is there any way to turn that of?

All these namespaces are used in different messages that get marshalled/unmarshalled by JAXB, but every message uses one namespace.

PS. I am not an XML expert please dont rant me if I did some stupid mistake ;)

© Stack Overflow or respective owner

Related posts about java

Related posts about jaxb