Hi,
I am using Xerces 2.4.0 to validate my xml documents.
The code is the usual parser stuff like
-----------
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setAttribute(" "dbf.setAttribute(.....) etc etc.
----------
My schema has a lot of rules with many restrictions on several nodes.
Whenever I give an invalid xml file (non conforming to my schema) to the parser, it throws SAXParseException.
These exceptions are logged in my logs.
For example,
org.xml.sax.SAXParseException: cvc-minInclusive-valid: Value '-240' is not facet-valid with respect to minInclusive '1'.
org.xml.sax.SAXParseException: cvc-minInclusive-valid: Value '-400' is not facet-valid with respect to minInclusive '1'.
org.xml.sax.SAXParseException: cvc-maxInclusive-valid: Value '40000000' is not facet-valid with respect to maxInclusive '1500'.
As you can see the error messages are not much useful. I want to get the name of the node in the xml file which caused
the problem. If I can get the name of the node/element in the xml file, I will be able to display more meaningful
error messages to the user such as:
"The value entered for cost is invalid: -240". etc.
Is there any way I can extract more information out of the SAXParseException,
so that I can get the node's name and/or value?
Thanks in advance.
I am using Xerces 2.4.0 to validate my xml documents.
The code is the usual parser stuff like
-----------
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setAttribute(" "dbf.setAttribute(.....) etc etc.
----------
My schema has a lot of rules with many restrictions on several nodes.
Whenever I give an invalid xml file (non conforming to my schema) to the parser, it throws SAXParseException.
These exceptions are logged in my logs.
For example,
org.xml.sax.SAXParseException: cvc-minInclusive-valid: Value '-240' is not facet-valid with respect to minInclusive '1'.
org.xml.sax.SAXParseException: cvc-minInclusive-valid: Value '-400' is not facet-valid with respect to minInclusive '1'.
org.xml.sax.SAXParseException: cvc-maxInclusive-valid: Value '40000000' is not facet-valid with respect to maxInclusive '1500'.
As you can see the error messages are not much useful. I want to get the name of the node in the xml file which caused
the problem. If I can get the name of the node/element in the xml file, I will be able to display more meaningful
error messages to the user such as:
"The value entered for cost is invalid: -240". etc.
Is there any way I can extract more information out of the SAXParseException,
so that I can get the node's name and/or value?
Thanks in advance.