Schema validation: Saxonica able to provide "error categories"?
Added by Mario Mueller over 6 years ago
Hello,
is Saxonica able to provide error categories for different kind of errors like
- missing node
- wrong value
- wrong format (e.g. string in node but only numbers are allowed)
Many Thanks Regards Mario Müller
Replies (2)
RE: Schema validation: Saxonica able to provide "error categories"? - Added by Michael Kay over 6 years ago
Saxon provides a reference to the XSD constraint name that is violated and you may be able to use this for categorisation. For example, if xsi:nil is present on an element that is not nillable, the Saxon Invalidity object will include constraint="cvc-elt", clause="3.1". This links back to the spec:
Validation Rule: Element Locally Valid (Element)
3 One of the following is true:
3.1 D.{nillable} = false, and E has no xsi:nil attribute.
The constraint names (e.g. cvc-elt
) are listed in Appendix B of the XSD specification. I wouldn't guarantee that Saxon always includes this information or that it always gives the most precise rule possible. For example, I see that if the maxExclusive
facet is violated, we appear to report (cvc-simple-type, 1) rather than (cvc-maxExclusive-valid, 1). Reporting (cvc-simple-type, 1) was appropriate with XSD 1.0 where the rule is:
For a string to be locally ·valid· with respect to a simple type definition all of the following must be true:
1 It is schema-valid with respect to that definition as defined by Datatype Valid in [XML Schemas: Datatypes].
but is less appropriate with XSD 1.1 where the the cvc-simple-type rules are now:
For a string S to be locally ·valid· with respect to a simple type definition T all of the following must be true:
1 The ·normalized value· of S, N, is calculated using the whiteSpace facet, and any other pre-lexical facets associated with T, as described in the definition of the term "·normalized value·".
2 N is schema-valid with respect to T as defined by Datatype Valid in [XML Schema: Datatypes].
RE: Schema validation: Saxonica able to provide "error categories"? - Added by Mario Mueller over 6 years ago
Hi Michael,
many thanks for the prompt and detailed answer. Regards Mario
Please register to reply