I'm trying to marshal objects into XML and I have a problem with the namespaces prefix (I don't want to have any prefix).
I'm using bindigs file to customize the generated classes. The generated package-info.java file contains the following:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.test.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://www.test.com", prefix = "")})
package com.test;
So, the prefix is set to "", but when the XML is generated, I have a generated prefix. If I use another value for prefix (different than an empty string), the XML is generated with the right prefix.
Your JAXB (JSR-222) implementation does not guarantee that it will use the prefixes specified in the @XmlSchema
annotation. EclipseLink JAXB (MOXy) will and so will recent versions of the JAXB RI.
The JAXB RI offers a NamespacePrefixMapper
extension which is now supported by MOXy to give more control over the prefixes used.
For More Information