<xsd:field> Element

Specifies an XML Path Language (XPath) expression that specifies the value (or one of the values) used to define an identity constraint (unique, key, and keyref elements).

<field
  id = ID 
  xpath = a subset of XPath expression 
  {any attributes with non-schema Namespace}...>
Content: (annotation?)
</field>

Attributes

  • id
    The ID of this element. The id value must be of type ID and be unique within the document containing this element.

    Optional.

  • xpath
    An XPath expression that is relative to each element selected by the selector of the identity constraint. This expression must identify a single element or attribute whose content or value is used for the constraint. If the expression identifies an element, that element must be of a simple type.

    Required.

Element Information

Number of occurrences

One time

Parent elements

key, keyref, unique

Contents

annotation

Remarks

An identity constraint must contain one or more field elements and those field elements must appear after the selector element.

Selector ::= Path ( '|' Path )*  
FieldXPath ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )  
Step ::= '.' | NameTest  
NameTest ::= QName | '*' | NCName ':' '*'  

Remarks

NoteNote

When using XPath, you must use fully qualified names if the name is defined with a non-empty targetNamespace. For example, myNS:localName instead of localName.

Example

The following fragment is a field element that specifies the myID attribute as the field to use for the identity constraint.

<xs:field xpath="@myID"/>

Other Resources

For more information see the W3C XML Schema Part 1: Structures Recommendation.

See Also

Reference

XML Schemas (XSD) Reference
XML Schema Elements