Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

Scope

Each identity constraint identifies a set of nodes that must be unique or that require referential integrity. Each identity constraint has a specific scope, which is the enclosing element type; any element type may provide any number of identity constraints.

In the example schema, the following schema excerpt specifies a key relative to the element type idConstraintDemo:

<xsd:element name= "idConstraintDemo">
    <xsd:complexType>

* * * *

  </xsd:complexType>

* * * *

  <xsd:key name="partNumberKey">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
        The part number uniquely identifies
        each orderable item.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:selector xpath="catalog/*"/>
    <xsd:field xpath="partNumber"/>
  </xsd:key>

* * * *

</xsd:element>

The example for this book was written awhile ago: in retrospect, the catalog should be a standalone element type in its own namespace (a good exercise!). Regardless, the existing schema demonstrates not only this key, but others that have the same scope as idConstraintDemo.

  • + Share This
  • 🔖 Save To Your Account