Share via


XML Schema Elements

XML Schema elements are grouped by their function: top level elements, particles, multiple XML documents and namespaces, identity constraints, attributes, named attributes, complex type definitions, and simple type definitions.

  • Top Level Elements

  • Particles

  • Multiple XML Documents and Namespaces

  • Identity Constraints

  • Attributes

  • Named Schema Objects

  • Complex Type Definitions

  • Simple Type Definitions

Top Level Elements

The following are elements that appear at the top level of a schema document.

Element Description

<xsd:annotation> Element

Defines an annotation.

<xsd:attribute> Element

Declares an attribute.

<xsd:attributeGroup> Element

Groups a set of attribute declarations so that they can be incorporated as a group for complex type definitions.

<xsd:complexType> Element

Defines a complex type, which determines the set of attributes and the content of an element.

<xsd:element> Element

Declares an element.

<xsd:group> Element

Groups a set of element declarations so that they can be incorporated as a group into complex type definitions.

<xsd:import> Element

Identifies a namespace whose schema components are referenced by the containing schema.

<xsd:include> Element

Includes the specified schema document in the target namespace of the containing schema.

<xsd:notation> Element

Contains the definition of a notation to describe the format of non-XML data within an XML document. An XML Schema notation declaration is a reconstruction of XML 1.0 NOTATION declarations.

<xsd:redefine> Element

Allows simple and complex types, groups, and attribute groups that are obtained from external schema files to be redefined in the current schema.

<xsd:simpleType> Element

Defines a simple type, which determines the constraints on and information about the values of attributes or elements with text-only content.

Particles

The following are elements that can have minOccurs and maxOccurs attributes. Such elements always appear as part of a complex type definition or as part of a named model group.

Element Description

<xsd:all> Element

Allows the elements in the group to appear (or not appear) in any order in the containing element.

<xsd:any> Element

Enables any element from the specified namespace(s) to appear in the containing sequence or choice element.

<xsd:choice> Element

Allows one and only one of the elements contained in the selected group to be present within the containing element.

<xsd:element> Element

Declares an element.

<xsd:group> Element

Groups a set of element declarations so that they can be incorporated as a group into complex type definitions.

<xsd:sequence> Element

Requires the elements in the group to appear in the specified sequence within the containing element.

Multiple XML Documents and Namespaces

The following are elements that bring in schema elements from other namespaces or redefine schema elements in the same namespace.

Element Description

<xsd:import> Element

Identifies a namespace whose schema components are referenced by the containing schema.

<xsd:include> Element

Includes the specified schema document in the target namespace of the containing schema.

<xsd:redefine> Element

Allows simple and complex types, groups, and attribute groups that are obtained from external schema files to be redefined in the current schema.

Identity Constraints

The following are elements that are related to identity constraints.


Element Description

<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).

<xsd:key> Element

Specifies that an attribute or element value (or set of values) must be a key within the specified scope. The scope of a key is the containing element in an instance document. A key must be unique, non-nillable, and always present.

<xsd:keyref> Element

Specifies that an attribute or element value (or set of values) correspond to those of the specified key or unique element.

<xsd:selector> Element

Specifies an XPath expression that selects a set of elements for an identity constraint (unique, key, and keyref elements).

<xsd:unique> Element

Specifies that an attribute or element value (or a combination of attribute or element values) must be unique within the specified scope. The value must be unique or nil.

Attributes

The following are elements that define attributes in schemas.

Element Description

<xsd:anyAttribute> Element

Enables any attribute from the specified namespace(s) to appear in the containing complexType element or in the containing attributeGroup element.

<xsd:attribute> Element

Declares an attribute.

<xsd:attributeGroup> Element

Groups a set of attribute declarations so that they can be incorporated as a group for complex type definitions.

Named Schema Objects

The following are elements that define named constructs in schemas. Named constructs are referred to with a QName by other schema elements.

Element Description

<xsd:attribute> Element

Declares an attribute.

<xsd:attributeGroup> Element

Groups a set of attribute declarations so that they can be incorporated as a group for complex type definitions.

<xsd:complexType> Element

Defines a complex type, which determines the set of attributes and the content of an element.

<xsd:element> Element

Declares an element.

<xsd:group> Element

Groups a set of element declarations so that they can be incorporated as a group into complex type definitions.

<xsd:key> Element

Specifies that an attribute or element value (or set of values) must be a key within the specified scope. The scope of a key is the containing element in an instance document. A key must be unique, non-nillable, and always present.

<xsd:keyref> Element

Specifies that an attribute or element value (or set of values) correspond to those of the specified key or unique element.

<xsd:notation> Element

Contains the definition of a notation to describe the format of non-XML data within an XML document. An XML Schema notation declaration is a reconstruction of XML 1.0 NOTATION declarations.

<xsd:simpleType> Element

Defines a simple type, which determines the constraints on and information about the values of attributes or elements with text-only content.

<xsd:unique> Element

Specifies that an attribute or element value (or a combination of attribute or element values) must be unique within the specified scope. The value must be unique or nil.

Complex Type Definitions

The following are elements that create complex type definitions.

Element Description

<xsd:all> Element

Allows the elements in the group to appear (or not appear) in any order in the containing element.

<xsd:annotation> Element

Defines an annotation.

<xsd:any> Element

Enables any element from the specified namespace(s) to appear in the containing sequence or choice element.

<xsd:anyAttribute> Element

Enables any attribute from the specified namespace(s) to appear in the containing complexType element or in the containing attributeGroup element.

<xsd:appinfo> Element

Specifies information to be used by applications within an annotation element.

<xsd:attribute> Element

Declares an attribute.

<xsd:attributeGroup> Element

Groups a set of attribute declarations so that they can be incorporated as a group for complex type definitions.

<xsd:choice> Element

Allows one and only one of the elements contained in the selected group to be present within the containing element.

<xsd:complexContent> Element

Contains extensions or restrictions on a complex type that contains mixed content or elements only.

<xsd:documentation> Element

Specifies information to be read or used by users within an annotation element.

<xsd:element> Element

Declares an element.

<xsd:extension> Element (simpleContent)

Contains extensions on simpleContent. This extends a simple type or a complex type that has simple content by adding specified attribute(s), attribute groups(s) or anyAttribute.

<xsd:extension> Element (complexContent)

Contains extensions on complexContent.

<xsd:group> Element

Groups a set of element declarations so that they can be incorporated as a group into complex type definitions.

<xsd:restriction> Element (simpleContent)

Defines constraints on a simpleContent definition.

<xsd:restriction> Element (complexContent)

Defines constraints on a complexContent definition.

<xsd:sequence> Element

Requires the elements in the group to appear in the specified sequence within the containing element.

<xsd:simpleContent> Element

Contains extensions or restrictions on a complexType element with character data or a simpleType element as content and contains no elements.

Simple Type Definitions

The following are elements that create simple type definitions.

Element Description

<xsd:annotation> Element

Defines an annotation.

<xsd:appinfo> Element

Specifies information to be used by applications within an annotation element.

<xsd:documentation> Element

Specifies information to be read or used by users within an annotation element.

<xsd:element> Element

Declares an element.

<xsd:list> Element

Defines a collection of a single simpleType definition.

<xsd:restriction> Element (simpleType)

Defines constraints on a simpleType definition

<xsd:union> Element

Defines a collection of multiple simpleType definitions.

See Also

Reference

XML Schemas (XSD) Reference
XML Data Types Reference
Primitive XML Data Types
Derived XML Data Types

Concepts

Data Type Facets