tsd:field

This element specifies information about the fields of a key (in the usage scenario with tsd:unique as parent) or fields to be indexed within a compound index (in the usage scenario with tsd:standard as parent).

It can be used in these two contexts:

  1. In the context of tsd:unique:

    Purpose In this context, the element specifies information about the fields of a key.
    Parent element tsd:unique
    Child elements None
    Attributes xpath
    Attributes
    Name Type Description
    xpath xs:string

    The xpath attribute specifies an XPath address uniquely identifying the field.

    The XPath expression is evaluated relative to the root element of the doctype being defined. Note that currently only paths consisting of "." or of the format

    ("/" element name)* "/" (element name | "@" attribute name)

    are allowed, but no filters.

    For more information on XPath, see the XML Path Language (XPath) Version 1.0 specification published by the W3C.

    Example 1

    This example demonstrates the use of the tsd:field element as a child element of tsd:unique.

    It contains the definition of one key using the "dot" option.

    <tsd:doctype name="A">
      .
      .
      . 
      <tsd:unique name="root-key">
        <tsd:field xpath="." />
      </tsd:unique>
      .
      .
      .
    </tsd:doctype>
    

    Example 2

    Here is another example of the tsd:field element as a child element of tsd:unique:

    <tsd:doctype name="A">
      .
      .
      .
      <tsd:unique name="CB-key">
        <tsd:field xpath="C" />
        <tsd:field xpath="B/@b" />
      </tsd:unique>
      <tsd:unique name="D-key">
        <tsd:field xpath="D" />
      </tsd:unique>
      .
      .
      .
    </tsd:doctype>
    

    It contains the definition of two keys:

    1. CB-key
      containing the fields C and B/@b

    2. D-key
      containing the field D

  2. In the context of tsd:standard:

    Purpose This element specifies information about the fields to be indexed in a compound index.
    Parent element tsd:standard
    Child elements None
    Attributes xpath
    Restriction tsd:field may appear as a child of tsd:standard only in the scope of a tsd:elementInfo element, because a compound index can be defined only for an element, not for an attribute.
    Attributes
    Name Type Description
    xpath xs:string

    The xpath attribute defines a component contributing to the compound index. A tsd:field element with a corresponding xpath attribute must be defined for each XPath address to be included in the compound index.

    Note:
    The tsd:field element must appear at least twice (with different xpath attributes) for two or more items whose XPath addresses are stored in the xpath attribute to define a valid compound index.

    Valid xpath values are:

    • A sequence of element names (optionally followed by a single attribute name), separated by slashes
      Any XPath expression that uses only the axes "child" and "attribute" and does not have more than one attribute.

    • A single dot "." denotes the element for which the compound index is being defined.

    The XPath expression is evaluated relative to the element for which the compound index is being defined.

    Important:
    The xpath attribute is required and must point to an existing element or attribute.

    Example

    In this example, two compound indexes are created in addition to a "normal" text index and a "normal" standard index:

    <xs:element ...>
      ...
      <tsd:elementInfo>
        <tsd:physical>
          [<tsd:which>...</tsd:which>]
          <tsd:native>
            <tsd:index>
              <tsd:text/>
              <tsd:standard/>
              <tsd:standard>
                <tsd:field xpath="C"/>
                <tsd:field xpath="B/@b" />
              </tsd:standard >
              <tsd:standard>
                <tsd:field xpath="D"/>
                <tsd:field xpath="B/@b" />
              </tsd:standard >
            ...
            </tsd:index>
          </tsd:native>
        </tsd:physical>
      </tsd:elementInfo>
    </xs:element>
    

    These are:

    • an index with entries for every combination of C and B/@b below the element;

    • an index with entries for every combination of D and B/@b below the element.