I have a XML file, and its xml schema contains couples complexType in it. So when I unmarshal the xml file, I want to give the xml parser my xml schema. Is it possible to do it, if so, then how to do it?
EDIT: After I unmarshal, every field in my object is null. Any idea why?
UPDATE
The issue you are seeing is due to the content being nested within the
NameAndAddresselement. You could introduce aNameAndAddressclass havePackageLabelhold an instance of that.PackageLabel
NameAndAddress
EclipseLink JAXB (MOXy)’s @XmlPath Extension
Alternatively you could use the
@XmlPathextension in EclipseLink JAXB (MOXy):For More Information
You can set an XML schema on an instance of Unmarshaller. This will cause JAXB to validate the input while it converts the XML to objects:
If you want to generate an object model from an XML schema, you can also use JAXB to do that: