Saxon extensions to XSD uniqueness and referential constraints

This extension is only available if enabled by specifying the attribute saxon:extensions="id-xpath-syntax" on the xs:schema element of the containing schema document.

The saxon:extensions attribute is a whitespace-separated list of keywords.

With this extension enabled, restrictions are removed on the syntax allowed in the selector/@xpath and field/@xpath attributes of the xs:unique, xs:key, and xs:keyref elements. Instead of the very limited XPath subset defined in the XSD 1.0 and XSD 1.1 specifications, Saxon will allow the same syntax as is permitted for streamable XPath expressions in XSLT. Specifically, the syntax for both attributes is the same as allowed in the select attribute of a streaming xsl:apply-templates, which is an extended form of the XSLT 3.0 syntax for patterns. It permits, for example, any sequence of downwards axes, arbitrary predicates on any step provided they do no downwards selection, and conditional expressions.

For example, the following is permitted, indicating that US-based employees must have a unique social security number, but not imposing any such constraint on other employees:

<xs:element name="company"> <xs:unique> <xs:selector xpath="employee[@location='us']"/> <xs:field xpath="@ssid"/> </xs:unique> </xs:element>