1

When using jaxb, it failed to unmarshall when the root element containing xmlns. How to fix it without changing xml data?

user496949
  • 83,087
  • 147
  • 309
  • 426

1 Answers1

3

You can use the package level @XmlSchema annotation to set the namespace qualification:

@XmlSchema(
    namespace = "http://www.example.org/package",
    elementFormDefault = XmlNsForm.QUALIFIED)
package example;

import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;

For more information see:

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • Thank you. I would like to know what does "elementFormDefault = XmlNsForm.QUALIFIED" mean here? – user496949 Mar 08 '11 at 10:40
  • It means that that for this package all elements will be qualified with this namespace URI. You can override this namespace URI in annotations like @XmlRootElement and @XmlElement. – bdoughan Mar 08 '11 at 10:43