When I use @XmlSchema(attributeFormDefault = XmlNsForm.QUALIFIED, ...)
or@XmlAttribute(namespace = "sample.com/y", ...)
JAXB ignores @XmlSchema(namespace = "sample.com/x", ...)
and instead of:
<a xmlns="sample.com/y" xmlns:ns0="sample.com/y">
<b ns0:att=""/>
</a>
generates something like:
<ns1:a xmlns:ns1="sample.com/x" xmlns:ns0="sample.com/y">
<ns1:b ns0:att=""/>
</ns1:a>
Is this an expected behavior? Is there any way to correct this?
EclipseLink JAXB (MOXy) is handling the prefix qualification for elements differently depending upon the attribute form qualification (as demonstrated below).
The namespace qualification is not wrong, but I agree that the use of default namespace is better when possible. You can track the progress on this issue using the following bug:
A
Demo
package-info without attributeFormDefault set
Output:
package-info with attributeFormDefault set
Output: