Handling Absent Components
The XSD 1.0 and 1.1 Recommendations both say that a schema should not be treated
as invalid merely because it contains unresolved references to absent schema components
(for example an xs:attribute
declaration that refers to a named type which
is not declared in the schema). The specification suggests that such a schema should
be usable for validation provided that the missing components are never used.
However, this strategy has complications:
- The effect of validation using such a schema is not very well defined, especially in XSD 1.0.
- The W3C test suite is written to treat such schemas as invalid (a processor that does what the spec says will fail over 500 tests).
- Users probably prefer to be told about the situation while the schema is under development, rather than when it is deployed in the field.
- It is much easier to produce clear diagnostics if the error is reported early.
By default therefore, Saxon treats missing component references as a compile-time error in the schema.
A configuration option, Feature.ALLOW_UNRESOLVED_SCHEMA_COMPONENTS.name, is available to change this
behavior. If this option is set, the schema processor attempts to repair the schema
to make it usable. For example, a reference to a missing type is replaced by a reference
to xs:error
(which has no valid instances); a reference to a missing
attribute group or model group is replaced by a reference to an empty attribute
group or model group; a reference to a missing element or attribute declaration is
replaced by a reference to a local element or attribute declaration with a declared
type of xs:error
.
One case where Saxon does not attempt a repair is where a type is derived from an absent base type. This is always a fatal error.
It is not possible to generate an SCM file when this configuration option is set; SCM files cannot contain dangling references.