Get invalid XML element instance



I've implemented an XML validator using this approach: How to get the element of and invalid xml file with failed xsd Validation


SAXParseException allows me to get line number, column number etc. What I wan is to record values of the element instance that was invalid. For example, if the XSD is:



<xs:schema xmlns:xs="http://ift.tt/tphNwY" elementFormDefault="qualified"
xmlns:vc="http://ift.tt/REsXlC" vc:minVersion="1.1">
<xs:element name="dimension">
<xs:complexType>
<xs:sequence>
<xs:element name="height" type="xs:integer"/>
<xs:element name="width" type="xs:integer"/>
</xs:sequence>
<xs:assert test="height le width"/>
</xs:complexType>
</xs:element>


I want to record the height or width of the dimension that was invalid. How do I do that?


The article proposes using validator.getProperty. But that returns java.lang.NullPointerException.


No comments:

Post a Comment