|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
How to extract some meaningful information from a SAXParseException?
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("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); 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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > How to extract some meaningful information from a SAXParseException? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|