This document is also available in these non-normative formats: XML.
Copyright © @@@@ W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
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.
This section describes the status of this specification at the time of its publication. Other specification may supersede this specification. 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.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft specification and may be updated, replaced or obsoleted by other specification at any time. It is inappropriate to cite this specification as other than work in progress.
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.
This document was produced by a Working 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.
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
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)
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.
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.
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]).
| 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/ |
A Document claiming conformance to this specification:
An implementation that claims conformance to this specification:
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].
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:
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.
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 is located from an [XML Schema 1.0] element node which may be the document element, or an 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.
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.
An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.[not(@elementFormDefault) or @elementFormDefault =
'unqualified']/ (., @elementFormDefault)An [XML 1.0] document 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 located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.[@attributeFormDefault = 'qualified']/
(@attributeFormDefault)An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document exhibits the
MixedContentElement pattern identified using the URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/MixedContentElement
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:element[@mixed = 'true']/ (@mixed)The following example [XML Schema 1.0] extract illustrates the use of the MixedContentElement pattern within an [XML Schema 1.0] document [ MixedContentElement]:
<xs:element name="mixedContentElement" type="ex:MixedContentElement" />
<xs:complexType mixed="true" name="MixedContentElement">
<xs:sequence>
<xs:element name="element1" type="xs:int" />
<xs:element name="element2" type="xs:string" />
<xs:element name="element3" type="xs:boolean" />
</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 [ MixedContentElement01]:
<ex:mixedContentElement> This is some mixed content containing an int <ex:element1>23</ex:element1> , a <ex:element2>string</ex:element2> and a boolean <ex:element3>true</ex:element3> </ex:mixedContentElement>
An [XML 1.0] document 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 located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:complexContent[@mixed = 'true']/ (@mixed)An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//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" />
An [XML 1.0] document 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 located by
//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)An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
./xs:element[@abstract='true']/ (@abstract)An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
./xs:element[@name]/xs:simpleType/ (../(., @name),
.)An [XML 1.0] document 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 located by
//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))))An [XML 1.0] document 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 located by
//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))An [XML 1.0] document 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 located by
//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)An [XML 1.0] document 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 located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
./xs:attribute/xs:simpleType/ (../(., @name), .)An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:element[@form='unqualified']/ (@form)An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document 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 located by
//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>
An [XML 1.0] document exhibits the
AttributeElementNameClash pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AttributeElementNameClash
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:complexType/xs:sequence/xs:element[@name =
../../xs:attribute/@name]/ (@name)The following example [XML Schema 1.0] extract illustrates the use of the AttributeElementNameClash pattern within an [XML Schema 1.0] document [ AttributeElementNameClash]:
<xs:element name="clientDetails" type="ex:ClientDetails" />
<xs:complexType name="ClientDetails">
<xs:sequence>
<xs:element name="forename" type="xs:string" />
<xs:element name="surname" type="xs:string" />
<xs:element name="title" type="xs:string" />
</xs:sequence>
<xs:attribute name="phone" type="xs:string" />
<xs:attribute name="title" type="xs:int" />
</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 [ AttributeElementNameClash01]:
<ex:clientDetails phone="+15556667788" title="1">
<ex:forename>Bobby</ex:forename>
<ex:surname>Sox</ex:surname>
<ex:title>Mr</ex:title>
</ex:clientDetails>
An [XML 1.0] document exhibits the
NillableOptionalElement pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/NillableOptionalElement
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:element[@nillable = 'true' and @minOccurs = '0']/
(@nillable, @minOccurs)Note, this specification places no particular
semantics on the difference between annotating an element with
xsi:nil and the absence of an element.
The following example [XML Schema 1.0] extract illustrates the use of the NillableOptionalElement pattern within an [XML Schema 1.0] document [ NillableOptionalElement]:
<xs:element name="nillableOptionalMiddleName" type="ex:NillableOptionalMiddleName" />
<xs:complexType name="NillableOptionalMiddleName">
<xs:sequence>
<xs:element name="firstName" type="xs:string" />
<xs:element name="middleName" type="xs:string" minOccurs="0" nillable="true" />
<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 [ NillableOptionalElement01]:
<ex:nillableOptionalMiddleName>
<ex:firstName>Paul</ex:firstName>
<ex:lastName>Downey</ex:lastName>
</ex:nillableOptionalMiddleName>
as is the following element when included in an instance document [ NillableOptionalElement02]:
<ex:nillableOptionalMiddleName>
<ex:firstName>Paul</ex:firstName>
<ex:middleName>Sumner</ex:middleName>
<ex:lastName>Downey</ex:lastName>
</ex:nillableOptionalMiddleName>
and the following element when included in an instance document [ NillableOptionalElement03]:
<ex:nillableOptionalMiddleName>
<ex:firstName>Paul</ex:firstName>
<ex:middleName xsi:nil="true"/>
<ex:lastName>Downey</ex:lastName>
</ex:nillableOptionalMiddleName>
An [XML 1.0] document exhibits the
ElementTypeReferenceUnqualified pattern identified using the
URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementTypeReferenceUnqualified
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:element[@name and @type and
namespace-uri-from-QName(resolve-QName(@type,.)) !=
'http://www.w3.org/2001/XMLSchema' and not(contains(@type, ':'))]/
(., @name, @type)An [XML 1.0] document exhibits the
ElementReferenceUnqualified pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementReferenceUnqualified
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:element[@ref and not(contains(@ref, ':'))]/ (.,
@ref)An [XML 1.0] document exhibits the
LocalElementSimpleType pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/LocalElementSimpleType
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:element[not(parent::xs:schema)]/xs:simpleTypeAn [XML 1.0] document exhibits the
AttributeFormQualified pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AttributeFormQualified
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:attribute[@form='qualified']/ (@form)An [XML 1.0] document exhibits the
ElementDefault pattern identified using the URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementDefault
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:element[@default]/ (@default)The following example [XML Schema 1.0] extract illustrates the use of the ElementDefault pattern within an [XML Schema 1.0] document [ GlobalElementDefault]:
<xs:element name="globalElementDefault" type="xs:string" default="theDefaultValue" />
The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ GlobalElementDefault01]:
<ex:globalElementDefault/>
as is the following element when included in an instance document [ GlobalElementDefault02]:
<ex:globalElementDefault>theDefaultValue</ex:globalElementDefault>
and the following element when included in an instance document [ GlobalElementDefault03]:
<ex:globalElementDefault>anotherValue</ex:globalElementDefault>
The following example [XML Schema 1.0] extract illustrates the use of the ElementDefault pattern within an [XML Schema 1.0] document [ ElementDefault]:
<xs:element name="elementDefault" type="ex:ElementDefault" />
<xs:complexType name="ElementDefault">
<xs:sequence>
<xs:element name="element" type="xs:string" default="default" />
</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 [ ElementDefault01]:
<ex:elementDefault>
<ex:element>default</ex:element>
</ex:elementDefault>
as is the following element when included in an instance document [ ElementDefault02]:
<ex:elementDefault>
<ex:element>wrong value</ex:element>
</ex:elementDefault>
An [XML 1.0] document exhibits the
AttributeRequired pattern identified using the URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AttributeRequired
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:attribute[@use = 'required']/ (@use)The following example [XML Schema 1.0] extract illustrates the use of the AttributeRequired pattern within an [XML Schema 1.0] document [ AttributeRequired]:
<xs:element name="attributeRequired" type="ex:AttributeRequired" />
<xs:complexType name="AttributeRequired">
<xs:sequence>
<xs:element name="percentage" type="xs:int" />
</xs:sequence>
<xs:attribute name="id" type="xs:string" />
<xs:attribute name="seasonal" type="xs:string" use="required" />
</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 [ AttributeRequired01]:
<ex:attributeRequired id="1611" seasonal="yes">
<ex:percentage>5</ex:percentage>
</ex:attributeRequired>
as is the following element when included in an instance document [ AttributeRequired02]:
<ex:attributeRequired id="1612" seasonal="no">
<ex:percentage>2</ex:percentage>
</ex:attributeRequired>
An [XML 1.0] document exhibits the
AttributeFixed pattern identified using the URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AttributeFixed
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:attribute[@fixed] / (@fixed)The following example [XML Schema 1.0] extract illustrates the use of the AttributeFixed pattern within an [XML Schema 1.0] document [ AttributeFixed]:
<xs:element name="attributeFixed" type="ex:AttributeFixed" />
<xs:complexType name="AttributeFixed">
<xs:sequence>
<xs:element name="fee" type="xs:int" />
</xs:sequence>
<xs:attribute name="id" type="xs:string" />
<xs:attribute name="currency" type="xs:string" fixed="GBP" />
</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 [ AttributeFixed01]:
<ex:attributeFixed id="1511" currency="GBP">
<ex:fee>500</ex:fee>
</ex:attributeFixed>
An [XML 1.0] document exhibits the
AttributeDefault pattern identified using the URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AttributeDefault
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:attribute[@default] / (@default)The following example [XML Schema 1.0] extract illustrates the use of the AttributeDefault pattern within an [XML Schema 1.0] document [ AttributeDefault]:
<xs:element name="attributeDefault" type="ex:AttributeDefault" />
<xs:complexType name="AttributeDefault">
<xs:sequence>
<xs:element name="text" type="xs:string" minOccurs="0" />
</xs:sequence>
<xs:attribute name="defaultedValue" type="xs:string" default="theDefaultValue" />
</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 [ AttributeDefault01]:
<ex:attributeDefault/>
as is the following element when included in an instance document [ AttributeDefault02]:
<ex:attributeDefault defaultedValue="theDefaultValue"/>
and the following element when included in an instance document [ AttributeDefault03]:
<ex:attributeDefault defaultedValue=""/>
and the following element when included in an instance document [ AttributeDefault04]:
<ex:attributeDefault defaultedValue="anotherValue"/>
An [XML 1.0] document exhibits the
AttributeReferenceUnqualified pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AttributeReferenceUnqualified
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:attribute[@ref and not(contains(@ref, ':'))]/ (.,
@ref)An [XML 1.0] document exhibits the
AttributeTypeReferenceUnqualified pattern identified using the
URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AttributeTypeReferenceUnqualified
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:attribute[@name and @type and
namespace-uri-from-QName(resolve-QName(@type,.)) !=
'http://www.w3.org/2001/XMLSchema' and not(contains(@type, ':'))]/
(., @name, @type)An [XML 1.0] document exhibits the
LocalAttributeSimpleType pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/LocalAttributeSimpleType
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:attribute[not(parent::xs:schema)]/xs:simpleTypeAn [XML 1.0] document exhibits the
GlobalComplexTypeAbstract pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalComplexTypeAbstract
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
./xs:complexType[@abstract='true']/ (@abstract)The following example [XML Schema 1.0] extract illustrates the use of the GlobalComplexTypeAbstract pattern within an [XML Schema 1.0] document [ GlobalComplexTypeAbstract]:
<xs:element name="globalComplexTypeAbstract" type="ex:GlobalComplexTypeAbstract" />
<xs:complexType name="GlobalComplexTypeExtra" abstract="true">
<xs:sequence>
<xs:element name="premium" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="GlobalComplexTypeAbstract">
<xs:complexContent>
<xs:extension base="ex:GlobalComplexTypeExtra" />
</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 [ GlobalComplexTypeAbstractExample01]:
<ex:globalComplexTypeAbstract>
<ex:premium>1175</ex:premium>
</ex:globalComplexTypeAbstract>
An [XML 1.0] document exhibits the
GlobalComplexTypeEmptyExtension pattern identified using the
URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/GlobalComplexTypeEmptyExtension
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
./xs:complexType[@name]/xs:complexContent[xs:extension[@base]/not(*)]/
(../../(., @name), .., ., xs:extension/(., @base))An [XML 1.0] document exhibits the
NMTOKENEnumerationType pattern identified using the URI
[RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/NMTOKENEnumerationType
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:simpleType/xs:restriction[@base/resolve-QName(.,..) =
xs:QName('xs:NMTOKEN') and xs:enumeration]/ (., @base,
xs:enumeration/(., @value))The following example [XML Schema 1.0] extract illustrates the use of the NMTOKENEnumerationType pattern within an [XML Schema 1.0] document [ NMTOKENEnumerationType]:
<xs:element name="nMTOKENEnumerationType" type="ex:NMTOKENEnumerationType" />
<xs:simpleType name="NMTOKENEnumerationType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="token1" />
<xs:enumeration value="token2" />
<xs:enumeration value="token3" />
</xs:restriction>
</xs:simpleType>
The following example [XML 1.0] element is valid against the above example [XML Schema 1.0] when included inside an instance document [ NMTOKENEnumerationType01]:
<ex:nMTOKENEnumerationType>token1</ex:nMTOKENEnumerationType>
An [XML 1.0] document exhibits the
IntEnumerationType pattern identified using the URI [RFC 3986]
http://www.w3.org/2002/ws/databinding/patterns/6/09/IntEnumerationType
when the following [XPath 2.0] expression
applied to a document or element node located by
//xs:schema results in an [XPath
2.0] node-set containing at least one node:
.//xs:simpleType/xs:restriction[@base/resolve-QName(.,..) =
xs:QName('xs:int') and xs:enumeration]/ (., @base,
xs:enumeration/(., @value))The following example [XML Schema 1.0] extract illustrates the use of the IntEnumerationType pattern within an [XML Schema 1.0] document [ IntEnumerationType]:
<xs:element name="intEnumerationType" type="ex:IntEnumerationType" />
<xs:simpleType name="IntEnumerationType">
<xs:restriction base="xs:int">
<xs:enumeration value="2" />
<xs:enumeration value="3" />
<xs:enumeration value="5" />
<xs:enumeration value="7" />
</