Hi everybody,

I want to improve the reported error details. I checked the sources of
XMLSchemaValidator and saw that method reportSchemaError() is called twice.
So for example processOneAttribute() has following sources for handling an
exception:

...
        catch (InvalidDatatypeValueException idve) {
            reportSchemaError(idve.getKey(), idve.getArgs());
            reportSchemaError(
                "cvc-attribute.3",
                new Object[] { element.rawname, fTempQName.rawname,
attrValue, 
                        (attDV instanceof XSSimpleTypeDecl) ? 
                                ((XSSimpleTypeDecl) attDV).getTypeName() :
attDV.getName()});
        }
...

Exception gets thrown, if there is an required attribute missing, like:

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 70;
cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'.

Since XML is not always accessible, it is hard to determine the related
element and attribute.

The second call of reportSchemaError() is not done, because
SAXParseException gets thrown by first method.

I added a custom error handler, that does not throw exception and simply
logs the message. The output is like I want to have it:

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 70;
cvc-attribute.3: The value '' of attribute 'id' on element 'course' is not
valid with respect to its type, 'integer'.

But now I have changed the behavior and no exception is thrown anymore,
which I do not want. So it is no final solution.

My questions are now:

Why is reportSchemaError() called twice?

How to get the log of second call without changing the current logic
(throwing exception)?



--
View this message in context: 
http://apache-xml-project.6118.n7.nabble.com/XMLSchemaValidator-calls-reportSchemaError-twice-tp43121.html
Sent from the Xerces - J - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to