Java xml validation: getting a better description of validation error

I am using javax.xml.validation.Validator from SchemaFactory.newInstance (XMLConstants.W3C_XML_SCHEMA_NS_URI) to perform an XSD check.

I would like to receive an error message for validation errors. All I get now is: org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'TypeCode'.

Is it possible to print an error, which element or xml fragment did not pass the test?

* Edit: I use standard java6 xml parsers * Edit2: Sorry for the lack of mention - I use JAXB to read XML using a content handler and listener (due to the fact that XML is> 1 GB in most cases).

+3
source share
2 answers

, (, Xerces ?), . , , Sun Multi-Schema Validator, , . DTD Woodstox , XML Schema MSV.

; / ( - ). , , , , SAX, SAX API.

+1

ErrorHandler Validator SAXParseException?

0

Source: https://habr.com/ru/post/1770043/


All Articles