When using jaxb, it failed to unmarshall when the root element containing xmlns. How to fix it without changing xml data?
Asked
Active
Viewed 493 times
1
-
Post your code and sample input XML. – Jim Garrison Mar 08 '11 at 03:34
-
Is that what you're looking for? (http://stackoverflow.com/questions/277502/jaxb-how-to-ignore-namespace-during-unmarshalling-xml-document) – mazaneicha Mar 08 '11 at 03:56
1 Answers
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