I am working with XML
and JAXB
as I am unmarshalling and marshalling the XML into Java objects and vice versa. Now I am trying to validate our XML
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: