Community
Participate
Working Groups
When marshalling an object containing an XmlAnyElement, and using element-form-default="QUALIFIED", duplicate namespace declarations are written out. Consider the following Java classes / XML Bindings file: ===== [package-info.java] @XmlSchema(elementFormDefault=XmlNsForm.QUALIFIED) package namespaces; [CustomerAnno.java] @XmlRootElement public class CustomerAnno { @XmlAnyElement public Object anyElem; } ===== <xml-schema element-form-default="QUALIFIED"/> <java-types> <java-type name="Customer"> <xml-root-element /> <java-attributes> <xml-any-element java-attribute="anyElem" /> </java-attributes> </java-type> </java-types> ===== If a namespace-qualified Element is set on anyElem: anyElem = doc.createElementNS("any-element", "my-elem"); Upon marshalling: Anno: class org.eclipse.persistence.jaxb.JAXBContext <?xml version="1.0" encoding="UTF-8"?> <customerAnno xmlns="http://www.example.org/root" xmlns:ns1="http://www.example.org/property" xmlns:ns0="http://www.example.org/type" id="0"> <my-elem xmlns="any-element" xmlns="any-element"/> </customerAnno> OXM: class org.eclipse.persistence.jaxb.JAXBContext <?xml version="1.0" encoding="UTF-8"?> <customer xmlns="http://www.example.org/root" xmlns:ns1="http://www.example.org/property" xmlns:ns0="http://www.example.org/type" ns0:id="0"> <my-elem xmlns="any-element" xmlns="any-element"/> </customer> * Note duplicate declaration of 'any-element' Also note that our formatting of the my-elem element is different from the RI's: Anno: class com.sun.xml.bind.v2.runtime.JAXBContextImpl <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns3:customerAnno xmlns="http://www.example.org/type" xmlns:ns2="http://www.example.org/property" xmlns:ns3="http://www.example.org/root" id="0"> <my-elem:my-elem xmlns:my-elem="any-element" xmlns="any-element"/> </ns3:customerAnno>
Created attachment 203859 [details] proposed fix and test
Attached patch checked in to SVN Reviewed by Denise Smith
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink