XML Schema 1.1 implementation
There is a change to the way in which unresolved references to schema components are handled.
The XSD specification (at both XSD 1.0 and 1.1) says that a schema should be treated
as valid even though it contains references to missing components (for example, an
attribute declaration referring to an xs:simpleType
that has not been
declared), provided that the missing components are not actually needed for validation.
This provision has always been rather unsatisfactory. Saxon has attempted to implement
it, but not always successfully. It doesn't help that the W3C conformance tests for XSD
expect such schemas to be reported as invalid.
In Saxon 10, by default, schemas containing such dangling references are reported as invalid.
A new configuration option is provided to accept dangling references. In this case the schema compiler outputs a warning, and (where possible) generates a schema in which the dangling references are "repaired".
The repair strategies are as follows:
- Missing reference to a type: the type is substituted by
xs:error
, a type with no valid instances. - Missing reference to a global element or attribute declaration: the declaration
is substituted with a local element or attribute having type
xs:error
. - Missing reference to a named attribute group or model group: the reference is replaced with a reference to an empty attribute group or model group. Note that this will not always lead to a run-time validation error.
- Missing reference to a substitution group: the reference is ignored.
- Missing reference from a type to its base type: this is always a fatal error and causes the schema to be treated as invalid.
In earlier releases, when a missing component was detected at run-time (that is, during
validation/assessment of a document instance) it was handled by throwing a
MissingComponentException
.
This exception has now been changed to an unchecked exception, so it does not have such an all-pervasive effect on the code. The result is that we can now attempt to provide more cases where absent components leave the schema usable; but with increased risk that references to components that are needed but absent cause a more severe failure when they occur.