XML Tutorial/XML Schema/IDREF

Материал из Web эксперт
Перейти к: навигация, поиск

The IDREF data type is derived from the NCName type.

IDREF refers to an element or attribute of type ID in the same instance document.
The value for IDREF must match a value for ID in the same instance document. 

<!-- schema -->
<xsd:element name="bank">
  <xsd:complexType>
   <xsd:complexContent>
    <xsd:extension base="xsd:anyType">
    <xsd:attribute name="branch" type="xsd:ID"/>
    </xsd:extension>
   </xsd:complexContent>
  </xsd:complexType>
</xsd:element>
<xsd:element name="city">
  <xsd:complexType>
   <xsd:complexContent>
    <xsd:extension base="xsd:anyType">
    <xsd:attribute name="branch_division"
     type="xsd:IDREF"/>
    </xsd:extension>
   </xsd:complexContent>
  </xsd:complexType>
</xsd:element>
<!-- instance document -->
<bank branch="412x">Northern</bank>
<city branch_division="412x">Chicago</city>