<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="schema-processing" page="extensions11"
               subpage="extended-uniqueness-constraints"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Saxon extensions to XSD uniqueness and referential constraints</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Saxon extensions to XSD uniqueness and referential constraints"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Saxon extensions to XSD uniqueness and referential constraints</h1>
      <p>This extension is only available if enabled by specifying the attribute <code>saxon:extensions="id-xpath-syntax"</code>
on the <code>xs:schema</code> element of the containing schema document.</p>
      <p>With this extension enabled, restrictions are removed on the syntax allowed in the <code>selector/@xpath</code> and <code>field/@xpath</code>
attributes of the <code>xs:unique</code>, <code>xs:key</code>, and <code>xs:keyref</code> 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 <code>xsl:apply-templates</code>, which is an extended form of the XSLT 2.1 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.</p>
      <p>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:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>
&lt;xs:element name="company"&gt;
  &lt;xs:unique&gt;
    &lt;xs:selector xpath="employee[@location='us']"/&gt;
    &lt;xs:field xpath="@ssid"/&gt;
  &lt;/xs:unique&gt;
&lt;/xs:element&gt;</code>
         </pre>
      </div>
      <table width="100%">
         <tr>
            <td>
               <p align="right"/>
            </td>
         </tr>
      </table>
   </body>
</html>