W3C

Advanced 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-advanced-20080328/
Latest version:
http://www.w3.org/TR/xmlschema-patterns-advanced
Previous versions:
http://www.w3.org/TR/2007/WD-xmlschema-patterns-advanced-20071031/
Editors:
Jonathan Calladine, BT
George Cowe, Origo Services Limited
Paul Downey, BT
Yves Lafon, W3C

Abstract

This specification provides a set of commonly used [XML Schema 1.0] patterns known to cause issues with some state of the art databinding implementations. The patterns in conjunction with the [Basic Patterns] may be used to describe XML 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. The Working Group plans to submit a subsequent version of this specification for consideration as a W3C Candidate Recommendation.

This document is a W3C Public Working Draft published to solicit comments from interested parties. Please submit comments on this document to the public public-xsd-databinding-comments@w3.org mailing list (public archive).

The Working Group solicits contributions to the test suite in the form of implementation reports and additional test cases.

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 ComplexType Declarations
    2.10 SimpleType Declarations
    2.11 ComplexType Declarations
    2.12 Sequences
    2.13 Choices
    2.14 Unions
    2.15 Lists
    2.16 Element Predefined Types
    2.17 Attribute Predefined Types
    2.18 Restricted Schema Types
    2.19 Numbers
    2.20 Group
    2.21 Unique
3. Data Types & Structures
    3.1 Default Value
    3.2 Map
    3.3 Extensible Enumeration
4. References
    4.1 Normative References
    4.2 Informative References

Appendices

A. Detecting Patterns (Non-Normative)
B. XPath 2.0 Idioms (Non-Normative)
C. Pattern Summary (Non-Normative)
D. Assertion Summary (Non-Normative)
E. Supported XML Schema elements, attributes and simple types (Non-Normative)
F. Relationship with the WS-I Basic Profile (Non-Normative)
G. Acknowledgements (Non-Normative)


1. Introduction

A databinding tool generates a mapping between XML 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] document to produce and consume [SOAP 1.2] messages in terms of data structures in a programming language or data held inside a database.

State of the art databinding implementations have displayed uneven and inconsistent support of the W3C [XML Schema 1.0] Recommendation. XML Schema provides a wide variety of methods for describing the same XML structure, conversely a concept such as "null" may be represented in a wide variety of different ways.

The result of these issues is impaired interoperability and a poor user experience of databinding tools:

This specification provides a advanced set of example [XML Schema 1.0] constructs and types in the form of concrete [XPath 2.0] expressions. These patterns are known to be in widespresd use and considered to be compatible with databinding implementations.

Implementers of databinding tools may find these patterns useful to represent simple and common place data structures. Ensuring tools recognise 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 the use 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 D. 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 consume any valid [XML Schema 1.0] Document.
  • 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 described 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 A. Detecting Patterns and 1.3 Document Conformance. Readers unfamiliar with [XPath 2.0] may find the list of B. 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

2.1.1 NoTargetNamespace

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the NoTargetNamespace pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/NoTargetNamespace 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(@targetNamespace)]/ (.)

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

<xs:schema>
  <xs:element name="noTargetNamespace" 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 [NoTargetNamespace01]:

  <noTargetNamespace>foo</noTargetNamespace>

2.1.2 UnqualifiedLocalElements

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the UnqualifiedLocalElements pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/UnqualifiedLocalElements 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(@elementFormDefault) or @elementFormDefault = 'unqualified']/ (., @elementFormDefault)

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

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/"  elementFormDefault="unqualified">
  <xs:element name="unqualifiedLocalElements" 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 [UnqualifiedLocalElements01]:

  <unqualifiedLocalElements>string</unqualifiedLocalElements>

2.1.3 QualifiedLocalAttributes

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the QualifiedLocalAttributes pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/QualifiedLocalAttributes 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:

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

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

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/"  attributeFormDefault="qualified">
  <xs:element name="qualifiedLocalAttributes" 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 [QualifiedLocalAttributes01]:

  <ex:qualifiedLocalAttributes>string</ex:qualifiedLocalAttributes>

2.1.4 FinalDefault

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the FinalDefault pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/FinalDefault 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:

./@finalDefault

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

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/" elementFormDefault="qualified"  finalDefault="#all">
  <xs:element name="finalDefault" 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 [FinalDefault01]:

  <ex:finalDefault>foo</ex:finalDefault>

2.1.5 BlockDefault

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the BlockDefault pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/BlockDefault 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:

./@blockDefault

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

<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/" elementFormDefault="qualified"  blockDefault="#all">
  <xs:element name="blockDefault" 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 [BlockDefault01]:

  <ex:blockDefault>foo</ex:blockDefault>

2.2 Annotations

2.2.1 AppinfoElement

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the AppinfoElement pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/AppinfoElement 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:appinfo/ (.., ., .//*, .//@*)

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

<xs:element name="appinfoElement" type="xs:string">
  <xs:annotation>
    <xs:appinfo />
  </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 [AppinfoElement01]:

  <ex:appinfoElement>some info</ex:appinfoElement>

2.3 Properties

2.3.1 MixedComplexContent

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the MixedComplexContent pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/MixedComplexContent 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:complexContent[@mixed = 'true']/ (@mixed)

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

<xs:element name="mixedComplexContent" type="ex:MixedComplexContent" />
<xs:complexType name="MixedComplexContent">
  <xs:complexContent  mixed="true">
    <xs:restriction base="xs:anyType">
      <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:restriction>
  </xs:complexContent>
</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 [MixedComplexContent01]:

  <ex:mixedComplexContent>
      <ex:element1>string</ex:element1>
  mixed content
  <ex:element2>string</ex:element2>
  mixed content
  <ex:element3>string</ex:element3>
  mixed content
</ex:mixedComplexContent>

2.3.2 MixedContentType

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the MixedContentType pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/MixedContentType 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[@mixed = 'true']/ (@mixed)

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

<xs:element name="mixedContentType" type="ex:MixedContentType" />
<xs:complexType name="MixedContentType"  mixed="true">
  <xs:sequence>
    <xs:element name="elem1" type="xs:string" />
    <xs:element name="elem2" 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 [MixedContentType01]:

  <ex:mixedContentType>
      <ex:elem1>Tagged Value</ex:elem1> mixed value <ex:elem2>Tagged Value</ex:elem2>
   </ex:mixedContentType>

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

  <ex:mixedContentType> some text <ex:elem1>Tagged Value</ex:elem1> more text <ex:elem2>Tagged
    Value</ex:elem2>
   </ex:mixedContentType>

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

  <ex:mixedContentType>
      <ex:elem1>Tagged Value</ex:elem1> mixed text value <ex:elem2>Tagged Value</ex:elem2> mixed
  text value </ex:mixedContentType>

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

  <ex:mixedContentType> text mixed value <ex:elem1>Tagged Value</ex:elem1>
      <ex:elem2>Tagged Value</ex:elem2> some more text in a mixed value </ex:mixedContentType>

2.4 Import and Include

2.4.1 ImportSchemaNamespace

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ImportSchemaNamespace pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ImportSchemaNamespace 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[not(@schemaLocation) and @namespace = 'http://www.w3.org/2001/XMLSchema']/ (., @namespace)

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

<xs:import namespace="http://www.w3.org/2001/XMLSchema" />
    

2.5 Global Element Declarations

2.5.1 GlobalElementUnqualifiedType

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementUnqualifiedType pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementUnqualifiedType 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 not(contains(@type, ':'))]/ (., @name, @type)

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

<xs:element name="globalElementUnqualifiedType"  type="GlobalElementUnqualifiedType" />
<xs:complexType name="GlobalElementUnqualifiedType">
  <xs:sequence>
    <xs:element name="element1" type="xs:string" />
    <xs:element name="element2" 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 [GlobalElementUnqualifiedType01]:

  <ex:globalElementUnqualifiedType>
      <ex:element1>string1</ex:element1>
      <ex:element2>string2</ex:element2>
   </ex:globalElementUnqualifiedType>

2.5.2 ElementTypeDefaultNamespace

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementTypeDefaultNamespace pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementTypeDefaultNamespace 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 not(contains(@type, ':'))]/ (@name, @type)

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

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

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

  <ex:stringElementDefaultNamespace/>

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

  <ex:stringElementDefaultNamespace>This is a string!</ex:stringElementDefaultNamespace>

2.5.3 GlobalElementAbstract

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementAbstract pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementAbstract 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='true']/ (@abstract)

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

<xs:element name="globalElementAbstract" type="ex:GlobalElementAbstract" />
<xs:complexType name="GlobalElementAbstract">
  <xs:sequence>
    <xs:element ref="ex:globalElementAbstractSubHead" />
  </xs:sequence>
</xs:complexType>
<xs:element name="globalElementAbstractSubHead"  abstract="true" />
<xs:element name="globalElementAbstractSub" substitutionGroup="ex:globalElementAbstractSubHead" />
    

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

  <ex:globalElementAbstract>
      <ex:globalElementAbstractSub>String</ex:globalElementAbstractSub>
   </ex:globalElementAbstract>

2.5.4 GlobalElementBlock

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementBlock pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementBlock 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/ (@block)

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

<xs:element name="globalElementBlock" type="xs:string"  block="#all" />
    

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

  <ex:globalElementBlock>Stuff</ex:globalElementBlock>

2.5.5 GlobalElementFinal

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementFinal pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementFinal 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/ (@final)

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

<xs:element name="globalElementFinal" type="xs:string"  final="#all" />
    

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

  <ex:globalElementFinal>Stuff</ex:globalElementFinal>

2.5.6 GlobalElementAll

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementAll pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementAll 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:all[xs:element]/ (../../(., @name), .., ., xs:element/(., @name))

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

<xs:element name="globalElementAll">
  <xs:complexType>
    <xs:all>
      <xs:element name="globalElementAllA" type="xs:string" />
      <xs:element name="globalElementAllB" type="xs:string" />
    </xs:all>
  </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 [GlobalElementAll01]:

  <ex:globalElementAll>
      <ex:globalElementAllA>one</ex:globalElementAllA>
      <ex:globalElementAllB>42</ex:globalElementAllB>
   </ex:globalElementAll>

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

  <ex:globalElementAll>
      <ex:globalElementAllB>42</ex:globalElementAllB>
      <ex:globalElementAllA>douze</ex:globalElementAllA>
   </ex:globalElementAll>

2.5.7 GlobalElementChoice

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementChoice pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementChoice 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:choice[xs:element]/ (../../(., @name), .., ., xs:element/(., @name))

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

<xs:element name="globalElementChoice">
  <xs:complexType>
    <xs:choice>
      <xs:element name="globalElementChoiceA" type="xs:string" />
      <xs:element name="globalElementChoiceB" type="xs:string" />
    </xs:choice>
  </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 [GlobalElementChoice01]:

  <ex:globalElementChoice>
      <ex:globalElementChoiceA>one</ex:globalElementChoiceA>
   </ex:globalElementChoice>

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

  <ex:globalElementChoice>
      <ex:globalElementChoiceB>two</ex:globalElementChoiceB>
   </ex:globalElementChoice>

2.5.8 GlobalElementSimpleType

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementSimpleType pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementSimpleType 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:simpleType/ (../(., @name), .)

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

<xs:element name="globalElementSimpleType">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="value1" />
      <xs:enumeration value="value2" />
      <xs:enumeration value="value3" />
    </xs:restriction>
  </xs:simpleType>
</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 [GlobalElementSimpleType01]:

  <ex:globalElementSimpleType>value1</ex:globalElementSimpleType>

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

  <ex:globalElementSimpleType>value2</ex:globalElementSimpleType>

2.5.9 GlobalElementComplexTypeSequenceExtension

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementComplexTypeSequenceExtension pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementComplexTypeSequenceExtension 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:complexContent[xs:extension[@base]/xs:sequence]/ (../../(., @name), .., ., xs:extension/(., @base, xs:sequence/(., xs:element/(., @name), xs:attribute/(., @name))))

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

<xs:element name="globalElementComplexTypeSequenceExtension">
  <xs:complexType>
    <xs:complexContent>
      <xs:extension base="xs:anyType">
        <xs:sequence />
      </xs:extension>
    </xs:complexContent>
  </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 [GlobalElementComplexTypeSequenceExtension01]:

  <ex:globalElementComplexTypeSequenceExtension>
      <ex:data> some data </ex:data>
   </ex:globalElementComplexTypeSequenceExtension>

2.5.10 GlobalElementComplexTypeEmptyExtension

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalElementComplexTypeEmptyExtension pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalElementComplexTypeEmptyExtension 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:complexContent[xs:extension[@base]/not(*)]/ (../../(., @name), .., ., xs:extension/(., @base))

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

<xs:element name="globalElementComplexTypeEmptyExtension">
  <xs:complexType>
    <xs:complexContent>
      <xs:extension base="xs:anyType" />
    </xs:complexContent>
  </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 [GlobalElementComplexTypeEmptyExtension01]:

  <ex:globalElementComplexTypeEmptyExtension/>

2.6 Global Attribute Declarations

2.6.1 GlobalAttributeUnqualifiedType

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalAttributeUnqualifiedType pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalAttributeUnqualifiedType 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 not(contains(@type, ':'))]/ (., @name, @type)

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

<xs:attribute name="globalAttributeUnqualifiedTypeAttr"  type="GlobalAttributeUnqualifiedTypeSimpleType" />
<xs:simpleType name="GlobalAttributeUnqualifiedTypeSimpleType">
  <xs:restriction base="xs:string">
    <xs:enumeration value="value1" />
    <xs:enumeration value="value2" />
  </xs:restriction>
</xs:simpleType>
<xs:complexType name="GlobalAttributeUnqualifiedType">
  <xs:sequence>
    <xs:element name="globalAttributeUnqualifiedTypeElement" type="xs:string" />
  </xs:sequence>
  <xs:attribute ref="ex:globalAttributeUnqualifiedTypeAttr" />
</xs:complexType>
<xs:element name="globalAttributeUnqualifiedType" type="ex:GlobalAttributeUnqualifiedType" />
    

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

  <ex:globalAttributeUnqualifiedType globalAttributeUnqualifiedTypeAttr="value1">
      <ex:globalAttributeUnqualifiedTypeElement>another
  string</ex:globalAttributeUnqualifiedTypeElement>
   </ex:globalAttributeUnqualifiedType>

2.6.2 GlobalAttributeSimpleType

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the GlobalAttributeSimpleType pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalAttributeSimpleType 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/xs:simpleType/ (../(., @name), .)

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

<xs:attribute name="globalAttributeSimpleTypeAttr">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="value1" />
      <xs:enumeration value="value2" />
      <xs:enumeration value="value3" />
    </xs:restriction>
  </xs:simpleType>
</xs:attribute>
<xs:complexType name="globalAttributeSimpleTypeComplexType">
  <xs:sequence>
    <xs:element name="globalAttributeSimpleTypeElement" type="xs:string" />
  </xs:sequence>
  <xs:attribute ref="ex:globalAttributeSimpleTypeAttr" />
</xs:complexType>
<xs:element name="globalAttributeSimpleType" type="ex:globalAttributeSimpleTypeComplexType" />
    

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

  <ex:globalAttributeSimpleType globalAttributeSimpleTypeAttr="value1">
      <ex:globalAttributeSimpleTypeElement>string</ex:globalAttributeSimpleTypeElement>
   </ex:globalAttributeSimpleType>

2.7 Element Declarations

2.7.1 ElementMinOccursFinite

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMinOccursFinite pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMinOccursFinite 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[xs:integer(@minOccurs) gt 1]/ (@minOccurs, @maxOccurs)

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

<xs:element name="elementMinOccursFinite" type="ex:ElementMinOccursFinite" />
<xs:complexType name="ElementMinOccursFinite">
  <xs:sequence>
    <xs:element name="elementMinOccursFiniteitem" type="xs:string"  minOccurs="3"  maxOccurs="3" />
  </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 [ElementMinOccursFinite01]:

  <ex:elementMinOccursFinite>
      <ex:elementMinOccursFiniteitem>item1</ex:elementMinOccursFiniteitem>
      <ex:elementMinOccursFiniteitem>item3</ex:elementMinOccursFiniteitem>
      <ex:elementMinOccursFiniteitem>item2</ex:elementMinOccursFiniteitem>
   </ex:elementMinOccursFinite>

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

<xs:element name="itemColors2" type="ex:ItemColors2" />
<xs:complexType name="ItemColors2">
  <xs:sequence>
    <xs:element name="itemColor" type="xs:string"  minOccurs="2"  maxOccurs="2" />
  </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 [ElementMinOccurs2MaxOccurs201]:

  <ex:itemColors2>
      <ex:itemColor>Red</ex:itemColor>
      <ex:itemColor>Yellow</ex:itemColor>
   </ex:itemColors2>

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

<xs:element name="itemColors" type="ex:ItemColors" />
<xs:complexType name="ItemColors">
  <xs:sequence>
    <xs:element name="itemColor" type="xs:string"  minOccurs="2"  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 [ElementMinOccurs2orMore01]:

  <ex:itemColors>
      <ex:itemColor>Red</ex:itemColor>
      <ex:itemColor>Black</ex:itemColor>
      <ex:itemColor>White</ex:itemColor>
      <ex:itemColor>Yellow</ex:itemColor>
   </ex:itemColors>

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

  <ex:itemColors>
      <ex:itemColor>Black</ex:itemColor>
      <ex:itemColor>White</ex:itemColor>
   </ex:itemColors>

2.7.2 ElementMinOccurs0MaxOccursFinite

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMinOccurs0MaxOccursFinite pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMinOccurs0MaxOccursFinite 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 and not(@maxOccurs = '0' or @maxOccurs = '1' or @maxOccurs = 'unbounded')]/ (@minOccurs, @maxOccurs)

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

<xs:element name="colorList" type="ex:ColorList" />
<xs:complexType name="ColorList">
  <xs:sequence>
    <xs:element name="colorValue" type="xs:string"  minOccurs="0"  maxOccurs="2" />
  </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 [ElementMinOccurs0MaxOccursFinite101]:

  <ex:colorList/>

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

  <ex:colorList>
      <ex:colorValue>red</ex:colorValue>
      <ex:colorValue>green</ex:colorValue>
   </ex:colorList>

2.7.3 ElementMaxOccursFinite

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementMaxOccursFinite pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMaxOccursFinite 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[@maxOccurs and not(@maxOccurs = '0' or @maxOccurs = '1' or @maxOccurs = 'unbounded')]/ (@maxOccurs)

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

<xs:element name="summer" type="ex:Summer" />
<xs:complexType name="Summer">
  <xs:sequence>
    <xs:element name="mnth" type="xs:string"  maxOccurs="4" />
  </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 [ElementMaxOccursFinite01]:

  <ex:summer>
      <ex:mnth>May</ex:mnth>
      <ex:mnth>June</ex:mnth>
      <ex:mnth>July</ex:mnth>
      <ex:mnth>August</ex:mnth>
   </ex:summer>

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

  <ex:summer>
      <ex:mnth>August</ex:mnth>
      <ex:mnth>September</ex:mnth>
   </ex:summer>

2.7.4 ElementFormUnqualified

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementFormUnqualified pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementFormUnqualified 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='unqualified']/ (@form)

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

<xs:element name="elementFormUnqualified" type="ex:ElementFormUnqualified" />
<xs:complexType name="ElementFormUnqualified">
  <xs:sequence>
    <xs:element name="element" type="xs:string"  form="unqualified" />
  </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 [ElementFormUnqualified01]:

  <ex:elementFormUnqualified>
      <element>string</element>
   </ex:elementFormUnqualified>

2.7.5 ChoiceElement

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ChoiceElement pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ChoiceElement 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:choice/xs:element/(.)

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

<xs:element name="choiceElement" type="ex:ChoiceElement" />
<xs:complexType name="ChoiceElement">
  <xs:choice>
    <xs:element name="AChoiceElement" type="xs:string" />
    <xs:element name="BChoiceElement" type="xs:string" />
  </xs:choice>
</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 [ChoiceElement01]:

  <ex:choiceElement>
      <ex:AChoiceElement>A</ex:AChoiceElement>
   </ex:choiceElement>

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

  <ex:choiceElement>
      <ex:BChoiceElement>B</ex:BChoiceElement>
   </ex:choiceElement>

2.7.6 AllElement

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the AllElement pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/AllElement 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:all/xs:element/(.)

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

<xs:element name="allElement" type="ex:AllElement" />
<xs:complexType name="AllElement">
  <xs:all>
    <xs:element name="element1" type="xs:string" />
    <xs:element name="element2" type="xs:string" />
    <xs:element name="element3" type="xs:string" />
    <xs:element name="element4" type="xs:string" />
    <xs:element name="element5" type="xs:string" />
  </xs:all>
</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 [AllElement01]:

  <ex:allElement>
      <ex:element1>element1</ex:element1>
      <ex:element2>element2</ex:element2>
      <ex:element3>element3</ex:element3>
      <ex:element4>element4</ex:element4>
      <ex:element5>element5</ex:element5>
   </ex:allElement>

2.7.7 ElementFixed

An [XML Schema 1.0], or other [XML 1.0] document containing an [XML Schema 1.0] element <xs:schema>, exhibits the ElementFixed pattern identified using the URI [RFC 3986] http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementFixed 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[@fixed] / (@fixed)