How to get more details from validation errors

J

Jorge Ortiz Claver

Hi,

I have to develop an application that is supposed to accept XML data.
I already have defined an XSD schema and validation against it works
properly.

Problem appears when my client, instead of error messages like

"The value 'AAA' of attribute 'code' on element
'comm-response' is not valid with respect to
its type, 'integer'.]"

(SAXException message) would like to receive error information
codified. Client only wants to receive a code for the tag that
produced the error (in this case, we will send a code assigned to tag
'AAA') and line/column information wouldn't be enough for him.

I tried to add a ContentHandler to the parser but it seems like
content-related events are fired before the validation process so I
can't keep control on what part of the XML file is being validated.

Thanks in advanced,
Jorge
 
J

Johannes Koch

Jorge said:
Problem appears when my client, instead of error messages like

"The value 'AAA' of attribute 'code' on element
'comm-response' is not valid with respect to
its type, 'integer'.]"

(SAXException message) would like to receive error information
codified. Client only wants to receive a code for the tag that
produced the error (in this case, we will send a code assigned to tag
'AAA') and line/column information wouldn't be enough for him.

In case you are using Xerces, you can overwrite the
XMLSchemaMessages.properties file. Bit of a hack, but it might work for you.
 
J

Jorge Ortiz

Thanks,

Good shoot! It doesn't fullfit all my requirements but it's a lot more
than I expected.

Trying to go further, is there any way to do it without hacking the
Xerces jar package ... let's say a multi-language configuration or
something like that?

Thanks again
Jorge
 
J

Jorge Ortiz

Thanks,

Good shoot! It doesn't fullfit all my requirements but it's a lot more
than I expected.

Trying to go further, is there any way to do it without hacking the
Xerces jar package ... let's say a multi-language configuration or
something like that?

Thanks again
Jorge
 
J

Johannes Koch

Jorge said:
Trying to go further, is there any way to do it without hacking the
Xerces jar package ... let's say a multi-language configuration or
something like that?

You can add XMLSchemaMessage_foo.properties and set the language to 'foo'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top