How to validate an XML against schema using JAXB?
You just need to set an instance of javax.xml.validation.Schema
on the Unmarshaller
before you do the unmarshal. You can specify an implementation of ValidationEventHandler
on the Unmarshaller
to catch any problems that occur during the unmarshal process.
For More Information
I have written more about this use case on my blog: