This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to get the error code of xml validation error ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to get the error code of xml validation error ?" Watch "How to get the error code of xml validation error ?" New topic
Author

How to get the error code of xml validation error ?

Sachin Kumar Khandelwal
Greenhorn

Joined: Dec 02, 2003
Posts: 8
Hi,

I'm validating an xml document against a schema, using javax.xml.validation.Validator .

It generates a SAXException when the document is invalid.
It displays the error code (such as cvc-attribute) in the message of exception .
But i need the error code in the program.
is there any way to get the generated error code.

Thanks in advance.

Sachin
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
Yes....

You need to create a valid validator handler for that which basically extends DefaultHandler.
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
Sachin Kumar Khandelwal
Greenhorn

Joined: Dec 02, 2003
Posts: 8
Hi Mike,

Thanks

The code in the url will give me the complete message, includes the error code and the description (handler.saxParseException.getMessage()) .

but i only want the error code (not the message or description).

Sachin
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Moving to XML...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to get the error code of xml validation error ?
 
Similar Threads
Help needed in XML Parsing
XSD Validation Failure
Tag files extensions
Exception while parsing XML document
How to get the error code of xml validation error ?