From: Peter Luttrell
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 07,
2005 11:58 AM
To: [email protected]
Subject: RE: Better Validation
Error Messages
Those methods would be really nice...but unfortunately
they return -1. Almost all other fields in XmlError object are also null.
Perhaps because i'm dynamically generating the XML with xmlbeans and then doing
post validation to make sure it's valid.
Here's
a more detailed example:
This XSD: <xsd:attribute name="Field"
type="xsd:integer" use="required" />
The code: whateverElement.setField( null );
Generates this XML: FieId=""
Which generates the error message: error: decimal: Invalid
decimal value: expected at least one digit
My
problem is unless I manually go through each element and attribute, I don't
have any idea what value isn't supplied.
Is
there any way to get better error messages, or at least some way to figure out
what element/attribute name is the cause of the problem?
-peter
|
"Jacob Danner"
<[EMAIL PROTECTED]>
09/06/2005 06:05 PM
|
|
I thought there was an API method on XMlError for
getting location information when its relevant. Try something like getLine
and/or getColumn()
XmlError err =
(XmlError)objects.next();
err.getLine();
-Jacobd
From: Peter Luttrell
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 2:45 PM
To: [email protected]
Subject: Better Validation Error Messages
Does anyone know how to get better validation error messages?
For example I just got this "cvc-minLength-valid.1.1: string length
(string) is less than minLength facet (0) for 4" How do I know what
element is causing this? I have quite a large XML Doc.
I tried casting the actual validationErrors coming back to XmlValidationErrors
(which is their type), but unfortunatly there isn't any relevant data in it's
fields.
Here's the code:
XmlOptions validationOptions = new XmlOptions();
validationOptions.setErrorListener( validationErrors );
if( !document.validate( validationOptions ) ) {
for( Iterator objects =
validationErrors.iterator(); objects.hasNext(); ) {
Object object =
objects.next();
if( object instanceof
XmlValidationError ) {
-peter ---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To
unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED]