<?xml version="1.0" encoding="UTF-8"?>
<!--
	source of advanced patterns specification
-->

<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.7//EN" "../common/xmlspec.dtd" [

<!ENTITY % entities SYSTEM "../common/entities.dtd" >
%entities;

<!ENTITY shortstatus "wd" >
<!ENTITY shortname "xmlschema-patterns" >
<!ENTITY status "Editors&apos; Copy $Date: 2009/03/19 21:17:41 $" >

<!ENTITY pubday "@@" >
<!ENTITY pubdd "@@" >
<!ENTITY pubmonth "@@@@" >
<!ENTITY pubnummonth "@@" >
<!ENTITY pubyear "@@@@" >

<!ENTITY prevshortstatus "wd" >
<!ENTITY prevpubday "@@" >
<!ENTITY prevpubdd "@@" >
<!ENTITY prevpubmonth "@@@@" >
<!ENTITY prevpubnummonth "@@" >
<!ENTITY prevpubyear "@@@@" >

<!ENTITY basic-pubmonth "@@@@" >
<!ENTITY basic-pubyear "@@@@" >
<!ENTITY basic-yymmdd "@@@@@@" >


<!ENTITY prefix "advanced" >
<!ENTITY review.end "1 December 2012" >

<!ENTITY namespaces SYSTEM "../basic/namespaces.xml">
<!ENTITY notations SYSTEM "../basic/notations.xml">
<!ENTITY patterns SYSTEM "patterns.xml">
<!ENTITY patterns-intro SYSTEM "../basic/patterns-intro.xml">
<!ENTITY pattern-summary SYSTEM "../common/pattern-summary.xml">
<!ENTITY pattern-summary-table SYSTEM "pattern-table.xml">
<!ENTITY ws-i-conformance SYSTEM "../basic/ws-i-conformance.xml">
<!ENTITY detecting-patterns SYSTEM "../basic/detecting-patterns.xml">
<!ENTITY xpath-idioms SYSTEM "../basic/xpath-idioms.xml">
<!ENTITY assertion-summary SYSTEM "../common/assertion-summary.xml">
<!ENTITY schema-summary SYSTEM "../common/schema-summary.xml">
<!ENTITY implementation-assertion-table SYSTEM "implementation-assertion-table.xml">
<!ENTITY document-assertion-table SYSTEM "document-assertion-table.xml">

]>

<spec w3c-doctype="other" role="edcopy">
  <header>
    <title>Advanced XML Schema Patterns for Databinding</title>
    <abstract><p>
This specification provides a set of commonly used <bibref ref="XMLSchema"/> patterns known to cause issues with some state of the art databinding implementations. 
The patterns in conjunction with the <bibref ref="BasicPatterns"/> 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.
</p>
    </abstract>
    <version>Version 1.0</version>
    <w3c-doctype>&status;</w3c-doctype>
    <altlocs>
        <loc role='xml' href='&prefix;.xml'>XML</loc>
    </altlocs>
    <pubdate>
      <day>&pubday;</day>
      <month>&pubmonth;</month>
      <year>&pubyear;</year>
    </pubdate>
    <publoc><loc href="http://www.w3.org/2002/ws/databinding/edcopy/advanced/advanced.html">http://www.w3.org/2002/ws/databinding/edcopy/advanced/advanced.html</loc></publoc>

    <authlist>
      <author>
        <name>Jonathan Calladine</name>
        <affiliation>BT</affiliation>
      </author>
      <author>
        <name>George Cowe</name>
        <affiliation>Origo Services Limited</affiliation>
      </author>
      <author>
	<name>Paul Downey</name>
	<affiliation>BT</affiliation>
      </author>
      <author>
	<name>Yves Lafon</name>
	<affiliation>W3C</affiliation>
      </author>

    </authlist>
    <status>
      <p><emph>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 <loc href="http://www.w3.org/TR/">W3C technical reports index</loc> at http://www.w3.org/TR/.</emph></p>

<p>This is a public Working Group Note produced by the <a href="http://www.w3.org/2002/ws/databinding/">XML Schema Patterns for Databinding Working Group</a>, which is part of the <a href=
"http://www.w3.org/2002/ws/Activity">W3C Web Services Activity</a>. This publication as a Working Group Note coincides with the end of the Working Group's charter period, and represents the culmination of the group's work.</p>
<p>
This document was built using evidence and experience gained examining the interoperability of a significant number of 
state of the art databinding implementations using a <loc href="http://www.w3.org/2002/ws/databinding/testsuite/">test suite</loc>, see the <loc href="http://www.w3.org/2002/ws/databinding/edcopy/report/advanced.html">Advanced Patterns Implementation Report</loc> and a collection of implementation reports including the <loc href="http://www.w3.org/2002/ws/databinding/edcopy/collection/">collection</loc> of patterns detected from "the wild".</p>

<p>The Working Group also produced an accompanying <bibref ref="BasicPatterns"/> document, which includes <bibref ref="XMLSchema"/> patterns in common use, but which were discovered to be well supported by state of the art databinding implementations.</p> 

<p>Publication as a Working Group Note 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.</p>
<p>This document was produced by a Working Group operating under the <loc href="http://www.w3.org/Consortium/Patent-Policy-20040205/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">5
  February 2004 W3C Patent Policy</loc>. The W3C maintains a <loc href="http://www.w3.org/2004/01/pp-impl/36696/status#specs" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">public
  list of any patent disclosures</loc> 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 <loc href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Essential
  Claim(s)</loc> must disclose the information in accordance with <loc href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">section
  6 of the W3C Patent Policy</loc>. </p>


    </status>

    <langusage>
      <language id="en-US">US English</language>
    </langusage>
  </header>
  <body>
    <div1 id="Introduction"><head>Introduction</head>
<p>
A databinding tool generates a mapping between XML documents which 
conform to an <bibref ref="XMLSchema"/> schema and an internal data representation.
For example, a Web services databinding tool may use <bibref ref="XMLSchema"/> descriptions inside a <bibref ref="WSDL20"/> document to produce and consume <bibref ref="SOAP12"/> messages in terms of data structures in a programming language or data held inside a database.
</p>
<p>
State of the art databinding implementations have displayed uneven and inconsistent
support of the W3C <bibref ref="XMLSchema"/> 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.
</p>

<p>
The result of these issues is impaired interoperability and a poor user experience of databinding tools:
</p>
<ulist>
    <item>rejecting valid XML Schema documents,</item>
    <item>rejecting valid XML instance documents, and</item>
    <item>making the content of valid XML instance documents unavailable in mapped data structures.</item>
</ulist>
<p>
This specification provides a advanced set of example <bibref ref="XMLSchema" /> constructs and types in the form of concrete <bibref ref="XPath20"/> expressions. These patterns are known to be in widespresd use and considered to be compatible with databinding implementations.</p>
<p>
 Implementers of databinding tools may find these patterns useful to represent simple and common place data structures. Ensuring tools recognise at least these simple <bibref ref="XMLSchema"/> 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 <bibref ref="XMLSchema"/> Recommendation. </p>

<!--
<ednote><name>pdowney</name><date>2006-10-11</date><edtext id="ISSUE-XX">ISSUE-XX</edtext></ednote>
-->


     &notations;

     &namespaces;

      <div2 id="document-conformance">
	<head>Document Conformance</head>
	    <p id="ISSUE-40">
		A Document claiming conformance to this specification:</p>
	    <ulist>
	    <item><assert class="document" id="assert-Unicode">MUST use either the UTF-8 or UTF-16 <bibref ref="Unicode"/> encoding.</assert></item>
	    <item><assert class="document" id="assert-BOM">MAY include the <bibref ref="Unicode"/> Byte Order Mark (<bibref ref="BOM"/>).</assert></item>
	    <item><assert class="document" id="assert-XML10">MUST be a Well-formed <bibref ref="XML"/> document</assert></item>
	    <item><assert class="document" id="assert-XMLSchema10">MUST conform to the <bibref ref="XMLSchema"/> Recommendation</assert></item>
	    <item id="ISSUE-16"><assert class="document" id="assert-BasicPatterns">MUST only contain <bibref ref="XML"/> element nodes and attribute nodes which form a part of one or more complete patterns contained in this and the <bibref ref="BasicPatterns"/> specifications.</assert></item>
	    <item><assert class="document" id="assert-CommentsAndPIs">MAY contain additional <bibref ref="XML"/> comment nodes and processing instruction nodes.</assert></item>
	    </ulist>

      </div2>
      <div2 id="implementation-conformance">
	<head>Implementation Conformance</head>
	    <p>An implementation that claims conformance to this specification:</p>
<ulist>
<item><assert class="implementation" id="assert-AnySchema">MUST be able to consume any valid <bibref ref="XMLSchema"/> Document.</assert></item> 
<item><assert class="implementation" id="assert-SchemaValid">MUST be able to process any <bibref ref="XMLSchema"/> Document conforming to this specification</assert></item> 
<item><assert class="implementation" id="assert-DataModel">MUST produce a data model exposing all of the <bibref ref="XML"/> element node and attribute node content described by the originating <bibref ref="XMLSchema"/> Document.</assert></item>
<item><assert class="implementation" id="assert-ConsumeXML">MUST be able to consume any Well-formed <bibref ref="XML"/> Document which satisfies local-schema validity against the originating <bibref ref="XMLSchema"/> Document exposing all of the <bibref ref="XML"/> element node and attribute node content in the data model.</assert></item>
<item><assert class="implementation" id="assert-ProduceXML">MUST be able to produce Well-formed <bibref ref="XML"/> instance documents which satisfy local-schema validity against the originating <bibref ref="XMLSchema"/> Document containing values exposed in the data model.</assert></item>
<item><assert class="implementation" id="assert-ConsumeInvalidAllowed">MAY consume Well-formed <bibref ref="XML"/> instance documents which do not satisfy local-schema validity against the originating <bibref ref="XMLSchema"/> Document.</assert></item>
<item><assert class="implementation" id="assert-ProduceInvalidAllowed">MAY allow the production of Well-formed <bibref ref="XML"/> instance documents containing values exposed in the data model which do not satisfy local-schema validity against the originating <bibref ref="XMLSchema"/> Document.</assert></item>
</ulist>

<p id="ISSUE-3">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, 
<code>xs:decimal</code>, 
<code>xs:integer</code>, 
<code>xs:negativeInteger</code>, 
<code>xs:positiveInteger</code>, 
<code>xs:nonNegativeInteger</code> and 
<code>xs:nonPositiveInteger</code>, 
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'.</p>

<p id="ISSUE-72">Note that although the patterns contained in this document are defined using <bibref ref="XPath20"/>, there is no requirement for a conformant implementation to support <bibref ref="XPath20"/>.</p>
      </div2>

    </div1>



    <div1 id="patterns"><head>Schema Patterns</head>

	&patterns-intro;


      <explanation xml:id="NillableOptionalElement">
	    <p id="ISSUE-7">
	    Note, this specification places no particular semantics on the difference between annotating an element with <code>xsi:nil</code> and the absence of an element.
	    </p>
      </explanation>

      <explanation xml:id="LanguageEnumerationType">
	    <p>Note, best current practice for the use of the <code>xs:language</code> type is described in <bibref ref="BCP47"/>.</p>
      </explanation>
      <explanation xml:id="LanguageElement">
	    <p id="lc-i18n-3-1">Note, best current practice for the use of the <code>xs:language</code> type is described in <bibref ref="BCP47"/>.</p>
      </explanation>
      <explanation xml:id="LanguageAttribute">
	    <p>Note, best current practice for the use of the <code>xs:language</code> type is described in <bibref ref="BCP47"/>.</p>
      </explanation>

	    &patterns;


    </div1>

    <div1 id="structures">
	<head>Data Types &amp; Structures</head>

<p id="ISSUE-37">
This section offers one or more patterns which may be used
to represent an abstract data structure.
Each data structure presented is intended to be independent of any particular programming language, 
database or modeling environment.
No semantics are implied by the order in which patterns are listed for a given abstract 
data structure.
</p>

      <div2 id="default"><head>Default Value</head>
	<glist>
	    <label>Definition</label>
	    <def>A preselected value used by when no alternative is explicitly specified.</def>
	    <label>Patterns</label>
	    <def>
	      <ulist>
	      </ulist>
	    </def>
	</glist>
      </div2>


      <div2 id="map"><head>Map</head>
	<p>
<ednote><name>pdowney</name><date>2006-10-25</date><edtext id="ISSUE-25">ISSUE-25: need to incorporate examples for Hash tables and maps</edtext></ednote>
	</p>
      </div2>

      <div2 id="extended-enum"><head>Extensible Enumeration</head>
<p>
<ednote><name>pdowney</name><date>2006-10-25</date><edtext id="ISSUE-5">ISSUE-5: need to incorporate extensible enum examples</edtext></ednote>
</p>
      </div2>

    </div1>


    <div1 id="refs">
      <head>References</head>

      <div2 id="normrefs">
        <head>Normative References</head>
	<blist>

	  <bibl key="Basic Patterns" id="BasicPatterns" href="http://www.w3.org/TR/xmlschema-patterns-&basic-yymmdd;/">
	    <titleref href="http://www.w3.org/TR/xmlschema-patterns">
		XML Schema Patterns for Databinding 1.0</titleref>, 
		Jonathan Calladine, George Cowe, Paul Downey, Yves Lafon, Editors. World Wide Web Consortium, &basic-pubmonth;, &basic-pubyear;.  The latest version of <loc href="http://www.w3.org/TR/xmlschema-patterns/">Basic Patterns</loc> is available at http://www.w3.org/TR/xmlschema-patterns/.</bibl> 

    <bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="XMLSchema" key="XML Schema 1.0" 
	    xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
	  Henry S. Thompson, David Beech, Murray Maloney, and Noah Mendelsohn, Editors. 
    World Wide Web Consortium.
    <emph>XML Schema, Parts 0, 1, and 2 (Second Edition)</emph>. W3C Recommendation, 28 October 2004. See 
    <loc href="http://www.w3.org/TR/xmlschema-0/" id="schema0" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/xmlschema-0/</loc>, 
    <loc href="http://www.w3.org/TR/xmlschema-1/" id="schema1" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/xmlschema-1/</loc>, and 
    <loc href="http://www.w3.org/TR/xmlschema-2/" id="schema2" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/xmlschema-2/</loc>.
    </bibl>


	  <bibl key="XPath 2.0" id="XPath20" href="http://www.w3.org/TR/2006/CR-xpath20-20060608/">
	    <titleref href="http://www.w3.org/TR/2006/CR-xpath20-20060608/">
		XML Path Language (XPath) 2.0</titleref>, 
		Don Chamberlin , Anders Berglund, Scott Boag, et. al., Editors. World Wide Web Consortium, 3 Nov 2005.  The <loc href="http://www.w3.org/TR/xpath20/">latest version</loc> 
		    is available at http://www.w3.org/TR/xpath20/.</bibl> 

	<bibl id="XMLNS" key="XML Namespaces"
	    href="http://www.w3.org/TR/1999/REC-xml-names-19990114">
	    <titleref>Namespaces in XML</titleref>, T. Bray, D. Hollander, and A.
	    Layman, Editors. World Wide Web Consortium, 14 January 1999. 
	    The <loc href="http://www.w3.org/TR/REC-xml-names">latest version</loc>
		is available at http://www.w3.org/TR/REC-xml-names.</bibl>

<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="XML" key="XML 1.0" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">World Wide Web Consortium.
<emph>Extensible Markup Language (XML) 1.0. (Fourth Edition)</emph>
W3C Recommendation, 16 August 2006.
See <loc href="http://www.w3.org/TR/REC-xml" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/REC-xml</loc>
</bibl>

	  <bibl key="RFC 2119" id="RFC2119" href="http://www.ietf.org/rfc/rfc2119.txt"><titleref href="http://www.ietf.org/rfc/rfc2119.txt">Key words for use in RFCs to Indicate Requirement Levels</titleref>, S. Bradner, Editor.  IETF, March 1997.</bibl> 

 <bibl id="RFC3986" key="RFC 3986" href="http://www.ietf.org/rfc/rfc3986.txt" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
	    <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Uniform Resource Identifiers (URI): Generic
	    Syntax</titleref>, T. Berners-Lee, R. Fielding, L. Masinter,
	    Authors. Internet Engineering Task Force, January 2005. 
	  </bibl>

<bibl id="Unicode" key="Unicode">
The Unicode Consortium. <emph>The Unicode Standard, Version 4.0</emph>. 
Reading, Mass.: Addison-Wesley, 2003, as updated from time to time by 
the publication of new versions.
(See 
<loc href="http://www.unicode.org/unicode/standard/versions">http://www.unicode.org/unicode/standard/versions</loc>
for the latest version and additional information on versions of the 
standard and of the Unicode Character Database)
</bibl>

	</blist>
      </div2>

      <div2 id="informrefs">
        <head>Informative References</head>
	<blist>

	    <bibl key="WSDL 2.0" id="WSDL20"
		href="http://www.w3.org/TR/2006/CR-wsdl20-20060106/">
		<titleref>Web Services Description Language (WSDL) Version 2.0 Part 1: Core
		    Language</titleref>, R. Chinnici, J. J. Moreau, A. Ryman, S.
		Weerawarana, Editors. World Wide Web Consortium, 6 January 2006.
		The <loc href="http://www.w3.org/TR/wsdl20">latest version</loc> is
		available at http://www.w3.org/TR/wsdl20.</bibl>

	  <bibl id="WSDL11" key="WSDL 1.1"
		href="http://www.w3.org/TR/2001/NOTE-wsdl-20010315">E. Christensen, et al,
	    <titleref>Web Services Description Language (WSDL) 1.1</titleref>, March 2001.</bibl>

		    <bibl id="SOAP12" key="SOAP 1.2"
                        href="http://www.w3.org/TR/2003/REC-soap12-part1-20030624/">
                        <titleref>SOAP Version 1.2 Part 1: Messaging Framework</titleref>, M.
                        Gudgin, M. Hadley, N. Mendelsohn, J-J. Moreau, H. Frystyk Nielsen, Editors.
                        World Wide Web Consortium, 24 June 2003. 
                        The <loc href="http://www.w3.org/TR/soap12-part1/">latest version</loc>
                            is available at http://www.w3.org/TR/soap12-part1/. </bibl>

                    <bibl id="SOAP11" key="SOAP 1.1"
                        href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508/"><titleref>Simple Object
                            Access Protocol (SOAP) 1.1</titleref>, D. Box, D. Ehnebuske, G.
                        Kakivaya, A. Layman, N. Mendelsohn, H Frystyk Nielsen, S. Thatte, D. Winer,
                        Editors. W3C Member Submission, 8 May 2000.</bibl>

	    <bibl key="XSLT 2.0" id="XSLT20"
		href="http://www.w3.org/TR/2006/CR-xslt20-20060608/">
		<titleref>XSL Transformations (XSLT) Version 2.0</titleref>, M. Kay, Editor. 
		World Wide Web Consortium, 8 June 2006.  The 
		    <loc href="http://www.w3.org/TR/xslt20/">latest version</loc> 
		    is available at http://www.w3.org/TR/xslt20.</bibl>

                    <bibl id="WSI-BP" key="WS-I Basic Profile 1.1"
			href="http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html"><titleref>WS-I Basic Profile 1.1</titleref>,
			Web Services Interoperability Organization, April 2004
		    The <loc href="http://www.ws-i.org/Profiles/BasicProfile-1.1.html">latest version</loc> and errata is available from http://www.ws-i.org/Profiles/BasicProfile-1.1.html.
			</bibl>

	  <bibl key="X.694" id="X.694" href="http://www.itu.int/ITU-T/studygroups/com17/languages/X694.pdf"> <titleref href="http://www.itu.int/ITU-R/">Information technology - ASN.1 encoding rules: Mapping W3C XML schema definitions into ASN.1</titleref>, International Telecommunications Union Recommendation. X.694 January 2004.  </bibl>

          <bibl key="Schematron" id="Schematron" href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c040833_ISO_IEC_19757-3_2006%28E%29.zip">
<titleref href="http://www.iso.org/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=40833&amp;ICS1=35&amp;ICS2=240&amp;ICS3=30">ISO/IEC 19757-3:2006</titleref>, Information technology - Document Schema Definition Languages (DSDL) - Part 3: Rule-based validation - International Standards Organization (JTC1/SC34) - <loc href="http://www.schematron.org">Schematron</loc>.  
	</bibl>

	    <bibl key="BOM" id="BOM" href="http://www.unicode.org/unicode/faq/utf_bom.html#BOM">
		<titleref>Unicode Frequently Asked Questions</titleref></bibl>

	     <bibl id="BCP47" key="BCP 47" href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
	     <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Best Current Practice Tags for Identifying Languages</titleref>, A. Phillips,  M. Davis,
	    Authors. The Internet Society, September 2006. 
	  </bibl>

	    <bibl key="Timezone" id="Timezone" href="http://www.w3.org/TR/2005/NOTE-timezone-20051013/">
		<titleref>Working with Time Zones</titleref>, Addison Phillips, Felix Sasaki, Mark Davis, Martin D&#252;rst, 
 Editors. World Wide Web Consortium, 13 October 2005.
		The <loc href="http://www.w3.org/TR/timezone/">latest version</loc> is
		available at http://www.w3.org/TR/timezone/.</bibl>

	</blist>
      </div2>

    </div1>
  </body>

  <back> 

    &detecting-patterns;

    &xpath-idioms;

    &pattern-summary;

    &assertion-summary;

    &schema-summary;

    &ws-i-conformance;

    &acknowledgements;

  </back>

</spec>

