XSD 1.1 (that is, version 1.1 of the “XML Schema Definition Language” defined by the World Wide Web Consortium) defines several attributes in a ‘version-control” namespace (VC) for use in XSD schema documents, to allow the same schema document to be used with schema processors supporting different versions of XSD.
VC-Filter uses an XSLT stylesheet to illustrate the principle. You can use it to experiment with different formulations and conditions, to see how the conditional-inclusion mechanism of the VC namespace works.
The stylesheet xsd.vc.xsl (which you can download and use locally if you wish) reads the document on the left, filters it according to the rules specified in the XSD 1.1 spec, and displays the result on the right.
The VC namespace has six attributes, which W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures (aka ‘the Schema spec’) defines as having the following meanings. Each attribute effectively defines a test, which succeeds or fails. Any element which fails any of the tests specified on it is filtered out of the schema document before the validator actually works on it. Each test involves comparing the value of the attribute against (a) the version number of the version of XSD supported by the processor (e.g. 1.0, 1.1, ...), (b) the names of the datatypes automatically provided by the processor (i.e. the built-in types, plus any implementation-defined types which are automatically included), and (c) the names of facets automatically provided by the processor.
Specifies a decimal number.
Succeeds if the XSD version supported by the processor is
greater than or equal to vc:minVersion
.
E.g. for a 1.1 processor, vc:minVersion="1.1"
succeeds, and
vc:minVersion="1.2"
fails. (Note that
minVersion applies an inclusive test.)
Specifies a decimal number.
Succeeds if the XSD version supported by the processor is
less than vc:maxVersion
.
E.g. for a 1.1 processor, vc:maxVersion="1.1"
fails
(“less than”, I said, not “less than or
equal to”), and
vc:maxVersion="1.2"
succeeds. (Note that
maxVersion applies an exclusive test.)
Specifies a list of QNames. Succeeds if all the QNames in the value are supported by the processor and made available automatically (as built-ins or as implementation-defined built-ins).
E.g. for a processor which supports only the built-in
datatypes, vc:typeAvailable="xs:decimal xs:anyURI"
succeeds
and
vc:typeAvailable="xs:decimal rdf:text"
fails.
Specifies a list of QNames. Succeeds if any of the QNames in the value are unavailable as automatically available (built-in) datatypes in this processor.
E.g. for a processor which supports only the built-in
datatypes, vc:typeUnavailable="xs:decimal xs:anyURI"
fails
and
vc:typeUnavailable="xs:decimal rdf:text"
succeeds.
Specifies a list of QNames. Succeeds if all the QNames in the value are supported by the processor as facets for the definition of new simple types.
E.g. for a processor which supports only the built-in
facets, vc:facetAvailable="xs:minInclusive xs:pattern"
succeeds
and
vc:facetAvailable="xs:minInclusive rdf:langRange"
fails.
Specifies a list of QNames. Succeeds if any of the QNames in the value are unavailable as automatically available (built-in) datafacets in this processor.
E.g. for a processor which supports only the built-in
datafacets, vc:facetUnavailable="xs:minInclusive xs:pattern"
fails
and
vc:facetUnavailable="xs:minInclusive rdf:langRange"
succeeds.
VC-Filter supports three parameters, to enable it to be used to experiment with different assumptions about the target processor (or: to filter schema documents for different target processors):
The version number of the target processor. This is the
number that gets compared to the values of the
vc:minVersion
and vc:maxVersion
attributes.
Default: 1.1
Expanded names of datatypes which should be assumed
to be built in to the processor and thus automatically
available. This list, plus the list of the built-in datatypes
defined by XSD 1.1, is used to determine whether the
vc:typeAvailable
and vc:typeUnavailable
attributes succeed or fail.
The value should take the form of a white-space delimited
list of expanded names of the form
“{nsname}localname
”.
Default: “{http://www.w3.org/1999/02/22-rdf-syntax-ns}text
”
Expanded names of facets which should be assumed
to be built in to the processor and thus automatically
available. This list, plus the list of the built-in facets
defined by XSD 1.1, is used to determine whether the
vc:facetAvailable
and vc:facetUnavailable
attributes succeed or fail.
The value should take the form of a white-space delimited
list of expanded names of the form
“{nsname}localname
”.
Default: “{http://www.w3.org/1999/02/22-rdf-syntax-ns}langRange
”
The known problems with VC-Filter are listed here.
Owing to a bug in the Mozilla implementation of XSLT,
the vc:typeAvailable
and vc:facetAvailable
attributes will not work correctly in Firefox or other Mozilla-based
browsers.
For simplicity, the namespace names in the additional datatypes and additional facets parameters currently are validated against the grammar of RFC 3986, appendix A. This has the effect of requiring them to be URIs; internationalized resource identifiers (IRIs) are not yet supported.
Version numbers are treated not a xsd:decimal numbers
but in the default Javascript and XSLT 1.0 way as 64-bit floating-point numbers.
This has the consequence that literals which are distinct as decimal
numbers but which map to the same floating-point value are treated
as equal. For example, vc:minVersion="1.100000000000001"
will succeed, instead of failing, for a processor supporting XSD 1.1.
The parameter for the processor version number is limited to ten
characters, so to exercise this bug the vc:minVersion
or vc:maxVersion
attributes in the input must have
values with more digits after the decimal point than are typically
found in a version number.