Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding out an invalid node in the SAXParseException

Status
Not open for further replies.

pbabka

Programmer
Jul 18, 2007
2
HU
Hi All,

It may be a stupid question...
I'm using a non-validating DOM parser and then a validator with a custom ErrorHandler on an element with a few child.
Can I figure out somehow what node or attribute cause a SAXParseException, or I should analyze the message returned by the getMessage() method of the exception object?

Thx
Peter
 
If you call the sax parser using command prompt / java to execute it, you will get the error message displayed
 
Hi,

It's OK, I know the message, I can read it with the getMessage()of the exception.
I would like to write a custom error handler what can determine which attribute/element is invalid.

Eg. I get exceptions with the following messages when the validator find an invalid integer attribute:

"cvc-datatype-valid.1.2.1: '62BB4926' is not a valid value for 'integer'."

"cvc-attribute.3: The value '62BB4926' of attribute 'AK' on element 'AK' is not valid with respect to its type, 'null'."

I search for a method to determine that the 'AK' attribute is not an integer.
Now I tokenize the message and read the 1st token to find out the type of error and read the 7th token to get a name of the attribute and read the 10th token to get the name of the element. But it's not a good practice, because the messages are not the same in all situation.

Regards
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top