I am trying to marsahall Objects to XML using jackson-dataformat-xml and woodstax but its adding additional namespace prefix wstxns1. Any suggestions ?
My Beans look like as below
@JacksonRootElement(localname="Blah" namespace="http://something"
Bla {
@JacksonXMLProperty(localname="SomeProperty" namespace="http://something"
String SomePropety;
@JacksonXMLProperty(localname="SomeClass" namespace="http://something-different"
Class SomeClass;
....
I assume that you want one of following:
XMLStreamWriter
allows this).Jackson XML module does not have mechanisms for handling prefixes at this point (although RFEs and pull requests are welcome). But Woodstox itself has fair bit of configurability, beyond basic Stax API (which is quite limited).
The places to look beyond (documentation, blogs) for additional configuration properties for output are classes:
org.codehaus.stax2.XMLOutputFactory2
for Stax2 extension properties (implemented by Woodstox and Aalto)com.ctc.wstx.api.WstxOutputProperties
for Woodstox-specific propertiesand these properties are set via
XMLOutputFactory.setProperty()
, same as standard Stax properties.Property of interest here would be
org.codehaus.stax2.XMLOutputFactory2#P_AUTOMATIC_NS_PREFIX
, which defaults to "wstxns" but can be changed to any other valid XML id String.Beyond this, it may be possible to specify pre-configured
XMLStreamWriter
for Jackson XML module to use. If so, it would also be possible to use standard Stax method ("writeNamespace()" I think?) to create specific prefix-to-URL namespace bindings.Finally, Jackson mailing lists are the best place to ask questions. Developers like myself do read StackOverflow and other forums as well, but latency tends to be higher as you have noticed.