Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

The keyref Element

The keyref identity constraint assures that each key sequence specified by the keyref exists, by virtue of equality, as a key sequence in the reference identity constraint. The reference identity constraint is always a unique or key identity constraint.

The following example specifies that every item in an order must exist in the list specified by the already specified partNumberKey:

<xsd:keyref name="partNumberRef"
      refer="partNumberKey">
  <xsd:annotation>
    <xsd:documentation xml:lang="en">
      Each order must refer to a known part number.
    </xsd:documentation>
  </xsd:annotation>
  <xsd:selector xpath="compressedOrder/order/item"/>
  <xsd:field xpath="partNumber"/>
</xsd:keyref>

Note that while this article does not provide examples (the book does!), a unique, key, and keyref each might specify multiple fields (that is, a multi-valued key such as "last name" and "first name" combined).

  • + Share This
  • 🔖 Save To Your Account