I am using the tutorial here for understanding JAXB.
When the writer comes to create the root of the document, the writer begins as below:
//This sta
I recommend using the package level @XmlSchema
annotation to specify the namespace qualification for you model. A package level annotation goes in a special class called package-info
that contains the exact content as shown below. That annotation will mean that all elements in your document without an explicit namespace given will use that namespace.
org/example/foo/package-info.java
@XmlSchema(
namespace = "http://www.example.org/foo",
elementFormDefault = XmlNsForm.QUALIFIED)
package org.example.foo;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
Overriding the Namespace
@XmlSchema
for all properties in a class using the @XmlType
annotation.@XmlRootElement
or @XmlElement
annotation.For More Information