Name

xsd:ID — Definition of unique identifiers

Synopsis

<xsd:simpleType name="ID” id="ID">
 <xsd:restriction base="xsd:NCName"/>
</xsd:simpleType>

Derived from

xsd:NCName

Primary

xsd:string

Known subtypes

None

Data parameters (facets)

enumeration, length, maxLength, minLength, pattern

Description

The purpose of the xsd:ID datatype is to define unique identifiers that are global to a document and emulate the ID attribute type available in the XML DTDs.

Unlike their DTD counterparts, W3C XML Schema ID datatypes can be applied to not only attributes but also simple element content.

For both attributes and simple element content, the lexical domain of these datatypes is the lexical domain of XML nonqualified names (xsd:NCName).

Identifiers defined using this datatype are global to a document and provide a way to uniquely identify their containing element, whatever its type and name is.

The constraint added by this datatype, beyond the xsd:NCName datatype from which it is derived, is that the values of all the attributes and elements that have an ID datatype in a document must be unique.

Note that the behavior of this datatype depends on whether the RELAX NG implementation supports RELAX NG DTD compatibility datatype library, in which case, the uniqueness of the identifiers will be checked. This datatype can be used both for elements and for defining multiple type assignment to attributes defined as ID, depending on their location in the schema.

Restrictions

Applications that need to maintain a level of compatibility with DTDs shouldn’t use this datatype for elements but should reserve it for attributes.

The lexical domain (xsd:NCName) of this datatype doesn’t allow the definition of numerical identifiers or identifiers containing whitespace.

Example

<element name="book">
  <element name="isbn">
    <data type="xsd:int"/>
  </element>
  <element name="title">
    <data type="xsd:string"/>
  </element>
  <element name="author-ref">
    <attribute name="ref">
      <data type="xsd:IDREF"/>
    </attribute>
  </element>
  <element name="character-refs">
    <data type="xsd:IDREFS"/>
  </element>
  <attribute name="identifier">
    <data type="xsd:ID"/>
  </attribute>
</element>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.125.109