I would like to have JAXB marshal to xml where the namespaces appear ONLY in the root element and not in any others:
<myroot xmlns="http://www.mysite.com" xmlns:a="http://www.mysite.com/a" xmlns:ab="http://www.mysite.com/ab" xmlns:y="http://www.mysite.com/y">
...
</myroot>
I've tried package level @XmlSchema, but I must be doing something wrong because nothing shows up.
Here is my root element class:
@XmlRootElement(name="myroot")
@XmlAccessorType(XmlAccessType.FIELD)
public class RootElementClass
{
....
}
I also have the following package-info.java:
@XmlSchema
(
namespace="http://www.mysite.com",
elementFormDefault=XmlNsForm.QUALIFIED,
xmlns=
{
@XmlNs(namespaceURI = "http://www.mysite.com", prefix = ""),
@XmlNs(namespaceURI = "http://www.mysite.com/a", prefix = "a"),
@XmlNs(namespaceURI = "http://www.mysite.com/ab", prefix = "ab"),
@XmlNs(namespaceURI = "http://www.mysite.com/y", prefix = "y")
}
)
package com.seastreetinc.rd.nso.jaxb;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;