Skip to main content

XML validation

1 reply [Last post]
euxx
Offline
Joined: 2003-06-10
Points: 0

I was looking at options to discover errors in XML data during parsing (e.g.. to nicely recover), but wasn't able to get far. The most you can get, is to configure SAX-based parser such as Xerces to continue parsing on any errors, implement custom error handler that would collect errors and then process these errors in document handler methods and clean/reset error list after processing of each element. The problem with this approach that errors (actually SAXException) does not have information about attribute names and the only way to get actual attribute names is to parse error message (which I consider nearly impossible).

I've looked at MSV tools, but there is no contextual error information either. More over I wasn't able to get all the errors for current element from MSV's Verifier.

Any ideas?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sandoz
Offline
Joined: 2003-06-20
Points: 0

Hi,

This is not the correct forum to ask such questions, as this is about binary-based Web services and XML. Perhaps we need an XML specific forum?

However, i will try and answer :-)

SAX does not provide an API for more detailed error information and AFAIK nor does Xerces (and relying parsing the error message string is not appropriate since this could change over releases). But you may want to look at Xerces specific exceptions held by the SAXParseException to see if there are certain methods to get access to more information. This will bind you to a specific implementation though.

It is not clear to me whether you are referring to well-formed errors or validation errors or both. Or in SAX parlance: warnings, error and fatalError.

Paul.