Copyright © 2006 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This specification provides a set of simple XML Schema 1.0 patterns which 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 or database or modelling environment.
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 is a First Public Working Draft and has been produced by the XML Schema Patterns for Databinding Working Group, part of the Web Services Activity in the W3C Architecture Domain. The authors of this document are the members of the W3C XML Schema Patterns for Databinding Working Group.
The document is in its early stage, readers should expect lots of changes and additions. A list of issues currently under consideration is available from the XML Schema Patterns for Databinding Working Group home page.
Please send comments about this document to public-xsd-databinding-comments@w3.org (with public archive). Discussions on this specification should take place on the :public-xsd-databinding@w3.org (with public archive)
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.
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.
1. Introduction
1.1 Notational
Conventions
1.2 Namespaces
1.3 Conformance
2. Data Types & Structures
2.1 String
Value
2.2 Boolean
Value
2.3 Decimal
Value
2.4 Null
Value
2.5 Default
Value
2.6 Enumeration
2.7 Collection
2.8 Vector
2.9 Inherited
Collection
3. Schema Patterns
3.1 Target Namespace
3.2 Qualified Local
Elements
3.3 Qualified Attributes
3.4 String
3.5 Boolean
3.6 Int
3.7 String Enumeration
3.8 Collection
3.9 Optional Element
3.10 Nillable Element
3.11 Nillable-Optional
Element
3.12 Simple
List
3.13 Wrapped Repeated
Element
3.14 Repeated Element
4. References
4.1 Normative
References
4.2 Informative
References
A. Acknowledgements
(Non-Normative)
This specification provides a set of example XML Schema structures [XML Schema Part 1: Structures Second Edition] and types [XML Schema Part 2: Datatypes Second Edition] which may be used to exchange commonly used data structures in the form of an XML document.
Authors of XML Schema 1.0 documents may find these patterns useful in providing a better user experience for consumers of schemata using data mapping and binding tools.
Implementers of tools which map or bind data structures to and from XML may find these patterns useful to represent simple and common place constructs. 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 may provide an improved user experience when using data mapping and binding tools.
This specification should not be used to constrain the use of the XML Schema 1.0 Recommendation. An XML Schema 1.0 processor should continue to provide support the whole of the XML Schema 1.0 Recommendation.
Whilst it is not possible to guarantee that schemata produced using these patterns will give a good user experience with the universal set of databinding tools, the patterns contained in this specification have been tested with a number of differnet tools covering a variety of different programming languages and environments.
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 [[RFC 2119]].
The notational convention of WS-Security [[WS-Security]] is used to describe XML content. Specifically, each member of an Element Information Item's [children] or [attributes] property is described using an XPath-like notation (e.g., /x:MyHeader/x:SomeProperty/@value1). The use of {any} indicates the presence of an element wildcard (<xs:any/>). The use of @{any} indicates the presence of an attribute wildcard (<xs:anyAttribute/>).
Editorial note: pdowney | 2006-04-26 |
Each pattern is defined using a series of {REQUIRED} or {OPTIONAL} XPath assertions which will be used to generate a validation tool. The tool is likely to be implemented using Schematron, subject to ISSUE-12 |
This specification presents a number of design issues an author of an XML Schema may wish to consider. Though the patterns presented by this specification are expected to be testable by tools to highlight possible interoperability problems with databinding and mapping tools, considerations have no impact on conformance.
Editorial note: pdowney | 2006-04-26 |
It's likely that a class of Design Considerations may result in "warnings" from a validation tool, in particular when a pattern is known not be to well supported by niche or an older versions of mainstream tools - ISSUE-35. |
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 [[XMLNS]]).
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 |
ex | http://www.w3.org/2002/ws/databinding/example |
Design Consideration
Several different patterns are provided for expressing the absence of a value, however minOccurs and nillable. Advice on when to use a given pattern is the subject of ISSUE-37.
Editorial note: pdowney | 2006-03-27 |
This section is likely to change subject to the resolution of ISSUE-7. |
Editorial note: pdowney | 2006-04-21 |
Section resulting from resolution of ISSUE-21 |
An XML Schema document conforming to this specification MUST define a targetNamesapce attribute.
An XML Schema document conforming to this specification MUST namespace qualify all locally defined elements using a schema element elementFormDefault attribute value of 'qualified'.
Attributes defined by a conformant Schema may be either be namespace qualified or unqualified under the control of the schema element attributeFormDefault attribute.
<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/testsuite/documents/" elementFormDefault="qualified"/>
<xs:schema targetNamespace="http://www.w3.org/2002/ws/databinding/testsuite/documents/" attributeFormDefault="unqualified" elementFormDefault="qualified"/>
An element or attribute defined by a conformant Schema may be of the type 'xs:string'.
<xs:element name="stringElement" type="xs:string"/>
<ex:stringElement>The World Wide Web Consortium (W3C)</ex:stringElement>
<ex:stringElement/>
<xs:element name="booleanElement" type="xs:boolean"/>
<ex:booleanElement>true</ex:booleanElement>
<ex:booleanElement>false</ex:booleanElement>
<ex:booleanElement>1</ex:booleanElement>
<ex:booleanElement>0</ex:booleanElement>
<xs:element name="intElement" type="xs:int"/>
<ex:intElement>42</ex:intElement>
<ex:intElement>-42</ex:intElement>
Design Consideration
text from resolution of ISSUE-6
<xs:element name="beatle" type="ex:Beatle"/> <xs:simpleType name='Beatle' > <xs:restriction base='xs:string' > <xs:enumeration value='John' /> <xs:enumeration value='Paul /> <xs:enumeration value='George' /> <xs:enumeration value='Stuart' /> <xs:enumeration value='Pete' /> <xs:enumeration value='Ringo' /> </xs:restriction> </xs:simpleType>
<ex:beatle>Paul</ex:beatle>
<ex:beatle>John</ex:beatle>
<ex:beatle>Ringo</ex:beatle>
<xs:element name="product" type="ex:Product"/> <xs:complexType name="Product"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="shade" type="xs:string"/> <xs:element name="length" type="xs:int"/> </xs:sequence> <xs:attribute name="id" type="xs:string" /> <xs:attribute name="inStock" type="xs:int" /> </xs:complexType>
<ex:product id="6026" inStock="232"> <ex:name>Widget</ex:name> <ex:shade>Light Blue</ex:shade> <ex:length>33</ex:length> </ex:product>
<ex:product inStock="52" id="6026"> <ex:name>Widget</ex:name> <ex:shade>Green</ex:shade> <ex:length>1233</ex:length> </ex:product>
<xs:element name="productBag" type="ex:ProductBag"/> <xs:complexType name="ProductBag"> <xs:all> <xs:element name="name" type="xs:string"/> <xs:element name="shade" type="xs:string"/> <xs:element name="length" type="xs:int"/> </xs:all> <xs:attribute name="id" type="xs:string" /> <xs:attribute name="inStock" type="xs:int" /> </xs:complexType>
<ex:productBag id="6026" inStock="232"> <ex:name>Widget</ex:name> <ex:length>33</ex:length> <ex:shade>Light Blue</ex:shade> </ex:productBag>
<ex:productBag inStocck="332" id="6026"> <ex:shade>Green</ex:shade> <ex:length>21</ex:length> <ex:name>Widget</ex:name> </ex:productBag>
<xs:element name="optionalMiddleName" type="ex:OptionalMiddleName"/> <xs:complexType name="OptionalMiddleName"> <xs:sequence> <xs:element name="firstName" type="xs:string"/> <xs:element name="middleName" type="xs:string" minOccurs="0"/> <xs:element name="lastName" type="xs:string"/> </xs:sequence> </xs:complexType>
<ex:optionalMiddleName> <ex:firstName>Paul</ex:firstName> <ex:lastName>Downey</ex:lastName> </ex:optionalMiddleName>
<ex:optionalMiddleName> <ex:firstName>Paul</ex:firstName> <ex:middleName>Sumner</ex:middleName> <ex:lastName>Downey</ex:lastName> </ex:optionalMiddleName>
<xs:element name="nillableMiddleName" type="ex:NillableMiddleName"/> <xs:complexType name="NillableMiddleName"> <xs:sequence> <xs:element name="firstName" type="xs:string"/> <xs:element name="middleName" type="xs:string" nillable="true"/> <xs:element name="lastName" type="xs:string"/> </xs:sequence> </xs:complexType>
<ex:nillableMiddleName> <ex:firstName>Paul</ex:firstName> <ex:middleName xsi:nil="true"/> <ex:lastName>Downey</ex:lastName> </ex:nillableMiddleName>
<ex:nillableMiddleName> <ex:firstName>Paul</ex:firstName> <ex:middleName>Sumner</ex:middleName> <ex:lastName>Downey</ex:lastName> </ex:nillableMiddleName>
<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>
<ex:nillableOptionalMiddleName> <ex:firstName>Paul</ex:firstName> <ex:lastName>Downey</ex:lastName> </ex:nillableOptionalMiddleName>
<ex:nillableOptionalMiddleName> <ex:firstName>Paul</ex:firstName> <ex:middleName>Sumner</ex:middleName> <ex:lastName>Downey</ex:lastName> </ex:nillableOptionalMiddleName>
<ex:nillableOptionalMiddleName> <ex:firstName>Paul</ex:firstName> <ex:middleName xsi:nil="true"/> <ex:lastName>Downey</ex:lastName> </ex:nillableOptionalMiddleName>
<xs:element name="itemList" type="ex:ItemList"/> <xs:complexType name="ItemList"> <xs:sequence> <xs:element name="item" type="xs:string" minOccurs=0 maxOccurs="unbounded"/> </xs:sequence> </xs:complexType>
<ex:itemList> <ex:item>first thing</ex:item> <ex:item>second thing</ex:item> <ex:item>third thing</ex:item> <ex:item>fourth thing</ex:item> </ex:itemList>
<xs:element name="contact" type="ex:Contact"/> <xs:complexType name="Contact"> <xs:sequence> <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="addressLine" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="telephoneNumber" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType>
<ex:customer> <ex:name>Benn</ex:name> <ex:addressLine>52, Festive Road</ex:addressLine> <ex:telephoneNumber>+44 207 946 0001</ex:telephoneNumber> </ex:customer>
<ex:customer> <ex:name>Mr</ex:name> <ex:name>Benn</ex:name> <ex:addressLine>52, Festive Road</ex:addressLine> <ex:addressLine>London</ex:addressLine> <ex:addressLine>England</ex:addressLine> <ex:telephoneNumber>+44 207 946 0001</ex:telephoneNumber> <ex:telephoneNumber>+44 7700 900 001</ex:telephoneNumber> </ex:customer>
This document is the work of the W3C XML Schema Patterns for Databinding Working Group.
Members of the Working Group are (at the time of writing, and by alphabetical order): Paul V. Biron (Health Level Seven, Inc.), Jonathan Calladine (BT), George Cowe (Origo Services Limited), Paul Downey (BT), Otu Ekanem (BT), Paul Fremantle (WSO2), Anthony Julian (Health Level Seven, Inc.), Yves Lafon (W3C/ERCIM), Ajith Ranabahu (WSO2).
Previous members of the Working Group were: Sekhar Vajjhala (Sun Microsystems).
The people who have contributed to discussions on public-xsd-databinding@w3.org are also gratefully acknowledged.