W3C

Basic XML Schema Patterns for Databinding Version 1.0

W3C Working Draft 28 March 2008

This version:
http://www.w3.org/TR/2008/WD-xmlschema-patterns-20080328/
Latest version:
http://www.w3.org/TR/xmlschema-patterns
Previous versions:
http://www.w3.org/TR/2007/WD-xmlschema-patterns-20071031/
Editors:
Jonathan Calladine, BT
George Cowe, Origo Services Limited
Paul Downey, BT
Yves Lafon, W3C

Abstract

This specification provides a set of basic [XML Schema 1.0] patterns known to be interoperable between state of the art databinding implementations. The patterns may be used to describe [XML 1.0] representations of commonly used data structures. The data structures described are intended to be independent of any particular programming language, database or modelling environment.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This document has been produced by the XML Schema Patterns for Databinding Working Group, which is part of the W3C Web Services Activity.

This is a second Last Call Public Working Draft published to solicit comments from interested parties and incorporates comments received since the first Last Call publication on 2006-11-22. Please submit comments on this document to the public public-xsd-databinding-comments@w3.org mailing list (public archive). The Last Call period ends 30 April 2008.

The Working Group plans to submit a subsequent version of this specification, incorporating community comments, to the W3C Director for consideration as a W3C Proposed Recommendation following a demonstration of the interoperability of a significant number of state of the art databinding implementations using the test suite, see the Basic Patterns Implementation Report (not a stable snapshot) and a collection of implementation reports including the collection of patterns detected from "the wild". (also a matter of work in progress)

The Working Group is also producing an accompanying [Advanced Patterns] document, which will include [XML Schema 1.0] patterns in common use, but which are not well supported by state of the art databinding implementations.

Since the previous Last Call publication the SequenceElement pattern has been added to this document, the following patterns have been moved to the [Advanced Patterns] document: AttributeFixed, AttributeRequired, Base64BinaryAttribute, Base64BinaryAttribute, GlobalElementBlock, GlobalElementFinal, GlobalComplexTypeBlock, FinalDefault, BlockDefault, DateAttribute, DateElement, DecimalAttribute, DecimalElement, DecimalSimpleTypeTotalDigits, ElementMaxOccursFinite, ENTITIESAttribute, ENTITIESElement, ENTITYAttribute, ENTITYElement, FloatAttribute, FloatElement, GlobalComplexTypeAbstract, GMonthDayAttribute, GMonthDayElement, GYearAttribute, GYearElement, GYearMonthAttribute, GYearMonthElement, IDAttribute, IDElement, IDREFAttribute, IDREFElement, IDREFSAttribute, IDREFSElement, IntegerAttribute, IntegerElement, LanguageAttribute, LanguageElement, NegativeIntegerAttribute, NegativeIntegerElement, NillableOptionalElement, NMTOKENAttribute, NMTOKENElement, NMTOKENEnumerationType, NMTOKENSAttribute, NMTOKENSElement, NonNegativeIntegerElement, NonPositiveIntegerAttribute, NonPositiveIntegerElement, SequenceMaxOccursFinite, SequenceMinOccurs0, MaxOccursUnboundedSequenceMinOccurs0MaxOccursUnbounded, MaxOccursUnboundedSequenceMinOccurs1MaxOccursUnbounded, TimeAttribute, TimeElement, UnsignedByteAttribute, UnsignedByteElement, UnsignedIntAttribute, UnsignedIntElement, UnsignedLongAttribute, UnsignedLongElement, UnsignedShortAttribute, UnsignedShortElement, the invalid ElementFinal pattern has been removed from this document, and the ImportTypesNamespace pattern has had its XPath value modified. Also, the assertion AnySchema has been removed.

All of the [XML Schema 1.0] patterns presented in this specification are considered to be "features at risk". The Working Group may elect to move a pattern from the specification into the [Advanced Patterns] document during the Last Call period subject to a demonstable lack of support in state of the art databinding implementations.

Patterns for [XML Schema 1.0] attributes which explicitly provide the default value, such as @minOccurs="1" may be added to this specification during Last Call as a result of the resolution to ISSUE-92, otherwise the Working Group does not expect to add patterns to this specification which introduce additional [XML Schema 1.0] elements or attributes.

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.


Table of Contents

1. Introduction
    1.1 Notational Conventions
    1.2 Namespaces
    1.3 Document Conformance
    1.4 Implementation Conformance
2. Schema Patterns
    2.1 Schema Element
    2.2 Annotations
    2.3 Properties
    2.4 Import and Include
    2.5 Global Element Declarations
    2.6 Global Attribute Declarations
    2.7 Element Declarations
    2.8 Attribute Declarations
    2.9 Global SimpleType Declarations
    2.10 Global ComplexType Declarations
    2.11 SimpleType Declarations
    2.12 ComplexType Declarations
    2.13 Sequences
    2.14 Element Predefined Types
    2.15 Attribute Predefined Types
3. References
    3.1 Normative References
    3.2 Informative References

Appendices

A. Data Types & Structures (Non-Normative)
    A.1 Null Value
    A.2 Default Value
    A.3 Enumeration
    A.4 Collection
    A.5 Inherited Collection
    A.6 Vector
B. Detecting Patterns (Non-Normative)
C. XPath 2.0 Idioms (Non-Normative)
D. Pattern Summary (Non-Normative)
E. Assertion Summary (Non-Normative)
F. Supported XML Schema elements, attributes and simple types (Non-Normative)
G. Relationship with the WS-I Basic Profile (Non-Normative)
H. Acknowledgements (Non-Normative)


1. Introduction

A databinding tool generates a mapping between [XML 1.0] documents which conform to an [XML Schema 1.0] schema and an internal data representation. For example, a Web services databinding tool may use [XML Schema 1.0] descriptions inside a [WSDL 2.0] or [WSDL 1.1] document to produce and consume [XML 1.0], [SOAP 1.2] and [SOAP 1.1] messages in terms of data structures in a programming language or data held inside a database.

[XML Schema 1.0] provides a wide variety of methods for describing the same [XML 1.0] structure. Conversely an abstract concept such as "null" may be represented in a wide variety of different ways using [XML Schema 1.0].

A representative collection of databinding implementations in common use has been used to provide an indication of the "state of the art". State of the art databinding implementations have displayed uneven and inconsistent support of the W3C [XML Schema 1.0] Recommendation resulting in impaired interoperability and a poor user experience of databinding tools:

This specification provides a basic set of example [XML Schema 1.0] constructs and types in the form of concrete [XPath 2.0] expressions. These patterns are known to work well with state of the art databinding implementations.

Authors of [XML Schema 1.0] documents may find these patterns useful in providing a better user experience for consumers of their schemata using databinding tools. Whilst it is not possible to guarantee that schemata produced using these patterns will give a good user experience with the universal set of databinding tools, the patterns contained in this specification have been all been tested with a number of different tools covering a variety of different programming languages and environments.

Implementers of databinding tools may find these patterns useful to represent simple and common place data structures. Ensuring tools recognize at least these simple [XML Schema 1.0] patterns and present them in terms most appropriate to the specific language, database or environment will provide an improved user experience when using databinding tools. It is inappropriate to use this specification to constrain implementation of the [XML Schema 1.0] Recommendation.

1.1 Notational Conventions

All parts of this specification are normative, with the EXCEPTION of notes, examples, and sections explicitly marked as Non-Normative.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this specification are to be interpreted as described in [RFC 2119].

Each [XML Schema 1.0] pattern is defined using a single [XPath 2.0] expression constraining one or more [XML Schema 1.0] items.

Each [XML Schema 1.0] pattern is identified using a unique and stable URI [RFC 3986].

Assertions about documents and implementations that are not enforced by the normative patterns are marked by a dagger symbol (†) at the end of a sentence. Each assertion has been assigned a unique and stable identifier. The assertion identifiers may be used by implementations of this specification for any purpose, such as error reporting. The assertions and their identifiers are summarized in section E. Assertion Summary.

1.2 Namespaces

This specification uses a number of namespace prefixes throughout; they are listed in Table 1-1. Note that the choice of any namespace prefix is arbitrary and not semantically significant (see [XML Namespaces]).

Table 1-1. Prefixes and Namespaces used in this specification
Prefix Namespace
xs http://www.w3.org/2001/XMLSchema
xsi http://www.w3.org/2001/XMLSchema-instance
soap11 http://schemas.xmlsoap.org/soap/envelope/
soap12 http://www.w3.org/2003/05/soap-envelope
wsdl11 http://schemas.xmlsoap.org/wsdl/
wsdl20 http://www.w3.org/2005/08/wsdl
pat http://www.w3.org/2002/ws/databinding/patterns/6/09/
ex http://www.w3.org/2002/ws/databinding/examples/6/09/

1.3 Document Conformance

A document claiming conformance to this specification:

1.4 Implementation Conformance

An implementation that claims conformance to this specification:

  • MUST be able to process any [XML Schema 1.0] document conforming to this specification
  • MUST produce a data model exposing all of the [XML 1.0] element node and attribute node content constrained by the originating [XML Schema 1.0] document.
  • MUST be able to consume any well-formed [XML 1.0] document which satisfies local-schema validity against the originating [XML Schema 1.0] document exposing all of the [XML 1.0] element node and attribute node content in the data model.
  • MUST be able to produce well-formed [XML 1.0] instance documents which satisfy local-schema validity against the originating [XML Schema 1.0] document containing values exposed in the data model.
  • MAY consume well-formed [XML 1.0] instance documents which do not satisfy local-schema validity against the originating [XML Schema 1.0] document.
  • MAY allow the production of well-formed [XML 1.0] instance documents containing values exposed in the data model which do not satisfy local-schema validity against the originating [XML Schema 1.0] document.

Describing the form of the data model provided by a databinding implementation is beyond the scope of this specification. For example, the unconstrained built-in numeric primitive types, xs:decimal, xs:integer, xs:negativeInteger, xs:positiveInteger, xs:nonNegativeInteger and xs:nonPositiveInteger, do not map directly to native types in many programming languages and are likely to be presented as a toolkit specific construct or more generalised ways, such as a 'string'.

Note that although the patterns contained in this document are defined using [XPath 2.0], there is no requirement for a conformant implementation to support [XPath 2.0].

2. Schema Patterns

This section defines the set of concrete [XML Schema 1.0] patterns which may appear inside a conformant document. A pattern definition includes the following information:

URI

A URI [RFC 3986] is provided to identify the pattern. The URI can be dereferenced to return informal documentation for the pattern including a list of examples and public schemas which exhibit the pattern.

XPath

A normative [XPath 2.0] expression, used to detect a pattern in an [XML Schema 1.0] document, returning a set of one or more XML element and attribute nodes. The [XPath 2.0] expression having a context node of an <xs:schema> element node which may be an [XML Schema 1.0] document element, or an <xs:schema> element contained inside an [XML 1.0] document such as [WSDL 2.0] description.

Note, the [XPath 2.0] expressions used to identify individual patterns may be wrapped inside an [XSLT 2.0] stylesheet or [Schematron] schema and used to detect [XML Schema 1.0] patterns contained in a [WSDL 2.0] or other document, see B. Detecting Patterns and 1.3 Document Conformance. Readers unfamiliar with [XPath 2.0] may find the list of C. XPath 2.0 Idioms used within this specification useful.

Examples

Optionally one or more non-normative [XML Schema 1.0] documents or fragments, followed by one or more valid instance document fragments.

A collection of patterns, including patterns beyond the scope of this specification, are available from http://www.w3.org/2002/ws/databinding/patterns/6/09/. This document offers no additional semantics for the schema patterns presented beyond those specified by the [XML Schema 1.0] Recommendation.

2.1 Schema Element

The xs:schema element MAY be the document element, but MAY also appear within other descriptions such as a [WSDL 2.0] or [WSDL 1.1] document.

2.1.1 TargetNamespace

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the TargetNamespace pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/TargetNamespace when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.[@targetNamespace]/ (., @targetNamespace)

An [XML Schema 1.0] document conforming to this specification MUST define a targetNamespace whose value is an absolute URI.

The following example [XML Schema 1.0] document [TargetNamespace] illustrates the use of the TargetNamespace pattern:

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/" elementFormDefault="qualified">
  <xs:element name="targetNamespace" type="xs:string" />
</xs:schema>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [TargetNamespace01]:

  <ex:targetNamespace>foo</ex:targetNamespace>

2.1.2 QualifiedLocalElements

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the QualifiedLocalElements pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/QualifiedLocalElements when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.[@elementFormDefault = 'qualified']/ (@elementFormDefault)

An [XML Schema 1.0] document conforming to this specification MUST namespace qualify all locally declared elements using a schema element elementFormDefault attribute value of qualified.

The following example [XML Schema 1.0] document [QualifiedLocalElements] illustrates the use of the QualifiedLocalElements pattern:

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/"  elementFormDefault="qualified">
  <xs:element name="qualifiedLocalElements">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="element1" type="xs:string" />
        <xs:element name="element2" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [QualifiedLocalElements01]:

  <ex:qualifiedLocalElements>
      <ex:element1>some data</ex:element1>
      <ex:element2>some more data</ex:element2>
   </ex:qualifiedLocalElements>

2.1.3 UnqualifiedLocalAttributes

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the UnqualifiedLocalAttributes pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/UnqualifiedLocalAttributes when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.[not(@attributeFormDefault) or @attributeFormDefault = 'unqualified']/ (., @attributeFormDefault)

The following example [XML Schema 1.0] document [UnqualifiedLocalAttributes] illustrates the use of the UnqualifiedLocalAttributes pattern:

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/"  attributeFormDefault="unqualified" elementFormDefault="qualified">
  <xs:element name="unqualifiedLocalAttributes" type="xs:string" />
</xs:schema>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [UnqualifiedLocalAttributes01]:

  <ex:unqualifiedLocalAttributes>foo</ex:unqualifiedLocalAttributes>

2.1.4 SchemaVersion

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the SchemaVersion pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/SchemaVersion when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./@version

The following example [XML Schema 1.0] document [SchemaVersion] illustrates the use of the SchemaVersion pattern:

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/" elementFormDefault="qualified"  version="this is version 42">
  <xs:element name="schemaVersion" type="xs:string" />
</xs:schema>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [SchemaVersion01]:

  <ex:schemaVersion>foo</ex:schemaVersion>

2.2 Annotations

2.2.1 DocumentationElement

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the DocumentationElement pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/DocumentationElement when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:annotation/xs:documentation/ (.., ., .//*, .//@*)

The following example [XML Schema 1.0] extract illustrates the use of the DocumentationElement pattern within an [XML Schema 1.0] document [DocumentationElement]:

<xs:annotation>
  <xs:documentation xml:lang="en" />
</xs:annotation>
<xs:element name="documentationElement" type="xs:string">
  <xs:annotation>
    <xs:documentation xml:lang="en" />
  </xs:annotation>
</xs:element>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [DocumentationElement01]:

  <ex:documentationElement>hello world</ex:documentationElement>

2.3 Properties

2.3.1 IdentifierName

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the IdentifierName pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/IdentifierName when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//.[matches(@name, "^[A-Za-z_]([A-Za-z0-9_]{0,31})$")]/ (@name)

Note, this pattern represents a subset of the native identifier formats supported by many, but not all, implementations and is therefore most likely to be supported by a databinding tools which directly maps an [XML 1.0] NCName to an native identifier.

The NCName used to declare an [XML 1.0] attribute MUST NOT be used as the declared NCName of a child element.

The following example [XML Schema 1.0] extract illustrates the use of the IdentifierName pattern within an [XML Schema 1.0] document [IdentifierName]:

<xs:element  name="identifierName" type="xs:string" />
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [IdentifierName02]:

  <ex:identifierName>Hello</ex:identifierName>

2.3.2 NonIdentifierName

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the NonIdentifierName pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/NonIdentifierName when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//.[@name and not(matches(@name, "^[A-Za-z_]([A-Za-z0-9_]{0,31})$"))]/ (@name)

The following example [XML Schema 1.0] extract illustrates the use of the NonIdentifierName pattern within an [XML Schema 1.0] document [NonIdentifierName]:

<xs:element  name="non-Identifier-Name" type="xs:string" />
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [NonIdentifierName02]:

  <ex:non-Identifier-Name>Hello</ex:non-Identifier-Name>

2.3.3 NotMixed

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the NotMixed pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/NotMixed when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//.[@mixed = 'false']/ (@mixed)

The following example [XML Schema 1.0] extract illustrates the use of the NotMixed pattern within an [XML Schema 1.0] document [NotMixed]:

<xs:element name="notMixed" type="ex:NotMixed" />
<xs:complexType name="NotMixed"  mixed="false">
  <xs:sequence>
    <xs:element name="notMixedElement" type="xs:string" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [NotMixedExample01]:

  <ex:notMixed>
      <ex:notMixedElement>Stuff</ex:notMixedElement>
   </ex:notMixed>

2.3.4 MinOccurs1

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the MinOccurs1 pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/MinOccurs1 when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//.[@minOccurs = '1']/ (@minOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the MinOccurs1 pattern within an [XML Schema 1.0] document [MinOccurs1]:

<xs:element name="minOccurs1" type="ex:MinOccurs1" />
<xs:complexType name="MinOccurs1">
  <xs:sequence>
    <xs:element name="value" type="xs:string"  minOccurs="1" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [MinOccurs01]:

  <ex:minOccurs1>
      <ex:value>44</ex:value>
   </ex:minOccurs1>

as is the following element when included in an instance document [MinOccurs02]:

  <ex:minOccurs1>
      <ex:value>4</ex:value>
      <ex:value>8</ex:value>
   </ex:minOccurs1>

2.3.5 MaxOccurs1

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the MaxOccurs1 pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/MaxOccurs1 when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//.[@maxOccurs = '1']/ (@maxOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the MaxOccurs1 pattern within an [XML Schema 1.0] document [MaxOccurs1]:

<xs:element name="maxOccurs1" type="ex:MaxOccurs1" />
<xs:complexType name="MaxOccurs1">
  <xs:sequence>
    <xs:element name="value" type="xs:string"  maxOccurs="1" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [MaxOccurs01]:

  <ex:maxOccurs1>
      <ex:value>44</ex:value>
   </ex:maxOccurs1>

as is the following element when included in an instance document [MaxOccurs02]:

  <ex:maxOccurs1>
      <ex:value>4</ex:value>
   </ex:maxOccurs1>

2.3.6 Id

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the Id pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/Id when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//@id

The following example [XML Schema 1.0] extract illustrates the use of the Id pattern within an [XML Schema 1.0] document [Id]:

<xs:element name="idExample" type="ex:IdExample"  id="node1" />
<xs:complexType name="IdExample"  id="node2">
  <xs:sequence  id="node3">
    <xs:element name="text" type="xs:string" minOccurs="0"  id="node4" />
  </xs:sequence>
  <xs:attribute name="string" type="xs:string"  id="node5" />
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [IdExample01]:

  <ex:idExample string="hello"/>

2.3.7 ComplexTypeConcrete

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ComplexTypeConcrete pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ComplexTypeConcrete when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:complexType[@abstract='false']/ (@abstract)

The following example [XML Schema 1.0] extract illustrates the use of the ComplexTypeConcrete pattern within an [XML Schema 1.0] document [ComplexTypeConcrete]:

<xs:element name="complexTypeConcrete" type="ex:ComplexTypeConcrete" />
<xs:complexType name="ComplexTypeConcrete"  abstract="false">
  <xs:sequence>
    <xs:element name="premium" type="xs:string" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ComplexTypeConcreteExample01]:

  <ex:complexTypeConcrete>
      <ex:premium>1175</ex:premium>
   </ex:complexTypeConcrete>

2.3.8 GlobalElementConcrete

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementConcrete pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementConcrete when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./xs:element[@abstract='false']/ (@abstract)

The following example [XML Schema 1.0] extract illustrates the use of the GlobalElementConcrete pattern within an [XML Schema 1.0] document [GlobalElementConcrete]:

<xs:element name="globalElementConcrete" type="xs:string"  abstract="false" />
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [GlobalElementConcreteExample01]:

  <ex:globalElementConcrete>Stuff</ex:globalElementConcrete>

2.4 Import and Include

2.4.1 ImportTypesNamespace

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ImportTypesNamespace pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ImportTypesNamespace when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:import[@namespace and not(@schemaLocation) and (@namespace = ../../xs:schema/@targetNamespace)]/ (., @namespace)

This pattern is designed to capture a reference to a namespace defined within a WSDL document types section.

The following example [XML Schema 1.0] extract illustrates the use of the ImportTypesNamespace pattern within an [XML Schema 1.0] document [ImportTypesNamespace]:

<wsdl>
  <xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/static/1" elementFormDefault="qualified">
    <xs:element name="importTypesNamespace" type="xs:string" />
  </xs:schema>
  <xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/static/2" elementFormDefault="qualified">
    <xs:import namespace="http://www.w3.org/2002/ws/databinding/examples/6/09/static/1" />
  </xs:schema>
</wsdl>
    

2.4.2 ImportNamespace

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ImportNamespace pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ImportNamespace when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./xs:import[@namespace and not(@schemaLocation) and not(@namespace = 'http://www.w3.org/2001/XMLSchema')]/ (., @namespace)

The following example [XML Schema 1.0] extract illustrates the use of the ImportNamespace pattern within an [XML Schema 1.0] document [ImportNamespace]:

<xs:import namespace="http://example.com/a/namespace" />
    

2.4.3 ImportSchema

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ImportSchema pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ImportSchema when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./xs:import[@namespace and @schemaLocation]/ (., @namespace, @schemaLocation)

The following example [XML Schema 1.0] extract illustrates the use of the ImportSchema pattern within an [XML Schema 1.0] document [ImportSchema]:

<xs:import namespace="http://example.com/a/namespace"  schemaLocation="http://www.w3.org/2002/ws/databinding/examples/6/09/static/Imported.xsd" />
    

2.4.4 Include

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the Include pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/Include when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./xs:include[@schemaLocation]/ (., @schemaLocation)

The following example [XML Schema 1.0] extract illustrates the use of the Include pattern within an [XML Schema 1.0] document [Include]:

<xs:include schemaLocation="http://www.w3.org/2002/ws/databinding/examples/6/09/static/Included.xsd" />
    

2.5 Global Element Declarations

2.5.1 GlobalElement

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElement pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElement when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./xs:element[@name and @type and contains(@type, ':')]/ (., @name, @type)

The following example [XML Schema 1.0] extract illustrates the use of the GlobalElement pattern within an [XML Schema 1.0] document [GlobalElement]:

<xs:element name="globalElement"  type="xs:string" />
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [GlobalElement01]:

  <ex:globalElement/>

as is the following element when included in an instance document [GlobalElement02]:

  <ex:globalElement>a value</ex:globalElement>

and the following element when included in an instance document [GlobalElement03]:

  <ex:globalElement>another Value</ex:globalElement>

2.5.2 GlobalElementSequence

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementSequence pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementSequence when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./xs:element[@name]/xs:complexType/xs:sequence[xs:element]/ (../../(., @name), .., ., xs:element/(., @name))

The following example [XML Schema 1.0] extract illustrates the use of the GlobalElementSequence pattern within an [XML Schema 1.0] document [GlobalElementSequence]:

<xs:element name="globalElementSequence">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="foo" type="xs:string" />
      <xs:element name="bar" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:element>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [GlobalElementSequence01]:

  <ex:globalElementSequence>
      <ex:foo>one</ex:foo>
      <ex:bar>two</ex:bar>
   </ex:globalElementSequence>

2.6 Global Attribute Declarations

2.6.1 GlobalAttribute

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalAttribute pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalAttribute when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

./xs:attribute[@name and @type and contains(@type, ":")]/ (., @name, @type)

The following example [XML Schema 1.0] extract illustrates the use of the GlobalAttribute pattern within an [XML Schema 1.0] document [GlobalAttribute]:

<xs:attribute name="globalAttributeAttr"  type="xs:string" />
<xs:complexType name="GlobalAttribute">
  <xs:sequence>
    <xs:element name="globalAttributeElement" type="xs:string" />
  </xs:sequence>
  <xs:attribute ref="ex:globalAttributeAttr" />
</xs:complexType>
<xs:element name="globalAttribute" type="ex:GlobalAttribute" />
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [GlobalAttribute01]:

  <ex:globalAttribute globalAttributeAttr="string">
      <ex:globalAttributeElement>another string</ex:globalAttributeElement>
   </ex:globalAttribute>

2.7 Element Declarations

2.7.1 ElementMinOccurs0

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMinOccurs0 pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMinOccurs0 when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:element[@minOccurs = '0' and (not(@maxOccurs) or @maxOccurs = '1')]/ (@minOccurs, @maxOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the ElementMinOccurs0 pattern within an [XML Schema 1.0] document [ElementMinOccurs0]:

<xs:element name="elementMinOccurs0" type="ex:ElementMinOccurs0" />
<xs:complexType name="ElementMinOccurs0">
  <xs:sequence>
    <xs:element name="firstName" type="xs:string" />
    <xs:element name="middleName" type="xs:string"  minOccurs="0" />
    <xs:element name="lastName" type="xs:string" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ElementMinOccurs001]:

  <ex:elementMinOccurs0>
      <ex:firstName>Paul</ex:firstName>
      <ex:lastName>Downey</ex:lastName>
   </ex:elementMinOccurs0>

as is the following element when included in an instance document [ElementMinOccurs002]:

  <ex:elementMinOccurs0>
      <ex:firstName>Paul</ex:firstName>
      <ex:middleName>Sumner</ex:middleName>
      <ex:lastName>Downey</ex:lastName>
   </ex:elementMinOccurs0>

2.7.2 ElementMinOccurs1

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMinOccurs1 pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMinOccurs1 when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:element[@minOccurs = '1' and (not(@maxOccurs) or @maxOccurs = '1')]/ (@minOccurs, @maxOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the ElementMinOccurs1 pattern within an [XML Schema 1.0] document [ElementMinOccurs1]:

<xs:element name="elementMinOccurs1" type="ex:ElementMinOccurs1" />
<xs:complexType name="ElementMinOccurs1">
  <xs:sequence>
    <xs:element name="elementMinOccurs1item" type="xs:string"  minOccurs="1" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ElementMinOccurs101]:

  <ex:elementMinOccurs1>
      <ex:elementMinOccurs1item>item1</ex:elementMinOccurs1item>
   </ex:elementMinOccurs1>

2.7.3 ElementMaxOccurs1

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMaxOccurs1 pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMaxOccurs1 when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:element[(not(@minOccurs) or @minOccurs = '1') and @maxOccurs = '1']/ (@minOccurs, @maxOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the ElementMaxOccurs1 pattern within an [XML Schema 1.0] document [ElementMaxOccurs1]:

<xs:element name="elementMaxOccurs1" type="ex:ElementMaxOccurs1" />
<xs:complexType name="ElementMaxOccurs1">
  <xs:sequence>
    <xs:element name="value" type="xs:string"  minOccurs="1"  maxOccurs="1" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ElementMaxOccurs101]:

  <ex:elementMaxOccurs1>
      <ex:value>44</ex:value>
   </ex:elementMaxOccurs1>

as is the following element when included in an instance document [ElementMaxOccurs102]:

  <ex:elementMaxOccurs1>
      <ex:value>4</ex:value>
   </ex:elementMaxOccurs1>

2.7.4 ElementMinOccurs0MaxOccursUnbounded

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMinOccurs0MaxOccursUnbounded pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMinOccurs0MaxOccursUnbounded when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:element[@minOccurs = '0' and @maxOccurs = 'unbounded']/ (@minOccurs, @maxOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the ElementMinOccurs0MaxOccursUnbounded pattern within an [XML Schema 1.0] document [NestedSequenceElementList]:

<xs:element name="nestedSequenceElementList" type="ex:NestedSequenceElementList" />
<xs:complexType name="NestedItem">
  <xs:sequence>
    <xs:element name="item"  minOccurs="0"  maxOccurs="unbounded" type="xs:string" />
  </xs:sequence>
</xs:complexType>
<xs:complexType name="NestedSequenceElementList">
  <xs:sequence>
    <xs:element name="nestedItem"  minOccurs="0"  maxOccurs="unbounded" type="ex:NestedItem" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [NestedSequenceElementList01]:

  <ex:nestedSequenceElementList>
      <ex:nestedItem>
         <ex:item>item onexone</ex:item>
         <ex:item>item onextwo</ex:item>
         <ex:item>item onexthree</ex:item>
         <ex:item>item onexfour</ex:item>
      </ex:nestedItem>
      <ex:nestedItem>
         <ex:item>item twoxone</ex:item>
         <ex:item>item twoxtwo</ex:item>
         <ex:item>item twoxthree</ex:item>
         <ex:item>item twoxfour</ex:item>
      </ex:nestedItem>
   </ex:nestedSequenceElementList>

The following example [XML Schema 1.0] extract illustrates the use of the ElementMinOccurs0MaxOccursUnbounded pattern within an [XML Schema 1.0] document [ElementMinOccurs0MaxOccursUnbounded]:

<xs:element name="durationList" type="ex:DurationList" />
<xs:complexType name="DurationList">
  <xs:sequence>
    <xs:element name="durationValue" type="xs:short"  minOccurs="0"  maxOccurs="unbounded" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ElementMinOccurs0MaxOccursUnbounded101]:

  <ex:durationList/>

as is the following element when included in an instance document [ElementMinOccurs0MaxOccursUnbounded102]:

  <ex:durationList>
      <ex:durationValue>24</ex:durationValue>
      <ex:durationValue>34</ex:durationValue>
      <ex:durationValue>44</ex:durationValue>
   </ex:durationList>

2.7.5 ElementMinOccurs1MaxOccursUnbounded

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMinOccurs1MaxOccursUnbounded pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMinOccurs1MaxOccursUnbounded when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:element[(not(@minOccurs) or @minOccurs = '1') and @maxOccurs = 'unbounded']/ (@minOccurs, @maxOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the ElementMinOccurs1MaxOccursUnbounded pattern within an [XML Schema 1.0] document [ElementMaxOccursUnbounded]:

<xs:element name="publications" type="ex:Publications" />
<xs:complexType name="Publications">
  <xs:sequence>
    <xs:element name="day" type="xs:string"  maxOccurs="unbounded" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ElementMaxOccursUnbounded01]:

  <ex:publications>
      <ex:day>2002-09-24</ex:day>
      <ex:day>2003-04-14</ex:day>
      <ex:day>2004-03-31</ex:day>
      <ex:day>2005-06-04</ex:day>
      <ex:day>2006-07-03</ex:day>
   </ex:publications>

as is the following element when included in an instance document [ElementMaxOccursUnbounded02]:

  <ex:publications>
      <ex:day>2006-01-26</ex:day>
   </ex:publications>

The following example [XML Schema 1.0] extract illustrates the use of the ElementMinOccurs1MaxOccursUnbounded pattern within an [XML Schema 1.0] document [ElementMinOccurs1MaxOccursUnbounded]:

<xs:element name="ageList" type="ex:AgeList" />
<xs:complexType name="AgeList">
  <xs:sequence>
    <xs:element name="ageValue" type="xs:short"  minOccurs="1"  maxOccurs="unbounded" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ElementMinOccurs1MaxOccursUnbounded101]:

  <ex:ageList>
      <ex:ageValue>44</ex:ageValue>
   </ex:ageList>

as is the following element when included in an instance document [ElementMinOccurs1MaxOccursUnbounded102]:

  <ex:ageList>
      <ex:ageValue>24</ex:ageValue>
      <ex:ageValue>34</ex:ageValue>
      <ex:ageValue>44</ex:ageValue>
   </ex:ageList>

2.7.6 ElementFormQualified

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementFormQualified pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementFormQualified when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:element[@form='qualified']/ (@form)

The following example [XML Schema 1.0] extract illustrates the use of the ElementFormQualified pattern within an [XML Schema 1.0] document [ElementFormQualified]:

<xs:element name="elementFormQualified" type="ex:ElementFormQualified" />
<xs:complexType name="ElementFormQualified">
  <xs:sequence>
    <xs:element name="premium" type="xs:string"  form="qualified" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ElementFormQualified01]:

  <ex:elementFormQualified>
      <ex:premium>1175</ex:premium>
   </ex:elementFormQualified>

2.7.7 SequenceElement

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the SequenceElement pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/SequenceElement when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:sequence/xs:element/(.)

The following example [XML Schema 1.0] extract illustrates the use of the SequenceElement pattern within an [XML Schema 1.0] document [SequenceElement]:

<xs:element name="sequenceElement" type="ex:SequenceElement" />
<xs:complexType name="SequenceElement">
  <xs:sequence>
    <xs:element name="element1" type="xs:string" />
    <xs:element name="element2" type="xs:string" />
    <xs:element name="element3" type="xs:string" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [SequenceElement01]:

  <ex:sequenceElement>
      <ex:element1>element1</ex:element1>
      <ex:element2>element2</ex:element2>
      <ex:element3>element3</ex:element3>
   </ex:sequenceElement>

2.7.8 SequenceSingleRepeatedElement

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the SequenceSingleRepeatedElement pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/SequenceSingleRepeatedElement when the following [XPath 2.0] expression applied to a document or element node with a context node of //xs:schema results in an [XPath 2.0] node-set containing at least one node:

.//xs:sequence[count(xs:element) = 1]/xs:element[@maxOccurs = 'unbounded']/ (., @maxOccurs)

The following example [XML Schema 1.0] extract illustrates the use of the SequenceSingleRepeatedElement pattern within an [XML Schema 1.0] document [SequenceSingleRepeatedElement]:

<xs:element name="sequenceSingleRepeatedElement" type="ex:SequenceSingleRepeatedElement" />
<xs:complexType name="SequenceSingleRepeatedElement">
  <xs:sequence>
    <xs:element name="element" type="xs:string"  maxOccurs="unbounded" />
  </xs:sequence>
</xs:complexType>
    

The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [