XML technologies / XML Schema / XML Schema element reference / xs:selector
(Excerpt from “XML Schema” by Eric van der Vlist)
Defining the path selecting an element for a uniqueness constraint.
<xs:selector
id = xs:ID
xpath = xs:token
{beliebige Attribute mit einem Nicht-Schema-Namensraum}
>
Content: (xs:annotation?)
</xs:selector>May occur within: xs:key, xs:keyref, xs:unique
Description
xs:selector specifies the element for which a uniqueness constraint or reference to one is checked. It cannot be an attribute, since attributes are already unique under XML 1.0. It is identified by a relative XPath expression.
The constraint is checked by running a loop over the XPath expression, interpreted relative to the constraint’s root element. That element is the location from which xs:field XPath expressions are resolved.
Restrictions
Attribute xpath uses a simple subset of XPath 1.0. The W3C XML Schema Working Group chose this both to simplify schema-processor implementation and to keep paths within the current element’s scope.
This subset of XPath uses only the axes child, self and descendant-or-self in abbreviated form, with no tests in any location step and no XPath functions. It is identical to the subset defined for xs:field , except that attributes are allowed in xs:field but forbidden in xs:selector.
The formal extended BNF (Backus–Naur form) in the W3C recommendation is:
Selector ::= Path ( ’|’ Path )* Path ::= (’.//’)? Step ( ’/’ Step )* Step ::= ’.’ | NameTest NameTest ::= QName | ’*’ | NCName ’:’ ’*’
Example
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
.../...
</xs:complexType>
<xs:unique name="book">
<xs:selector xpath="book"/>
.../...
</xs:unique>
</xs:element>Attributes
id
Element ID according to W3C XML Schema.
xpath
Relative XPath expression identifying an element to which the constraint applies.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de