Skip to main content

JAXB validation - how to throw an exception

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
jvsrvcs
Offline
Joined: 2012-04-18

I am using JAXB ( JDK 1.6 ), I have a ValidationEventHandler,

I am validating each .xml file against a .xsd; when this fails the ValidationEventHandler is called; Inside the validation handler, I simply print out the tags not expected;

I need to know when this validation handler is called to handle additional logic; If the validation handler would run and then throw an exception, I could do what I need, but it does not throw an exception, and I cannot throw an exception inside the handler.

If the XML file could not be validated, I want to move the file to another directory but I see no way to do this; if there is a way, please let me know. Please respond only if you have a solution that will work.