<?xml version='1.0'?>
<?xml:stylesheet type='text/xsl' href='xmlschema.msxsl'?>
<!-- $Id: structures.xml,v 1.45.1.6 1999/12/17 16:14:53 ht Exp $ -->
<!DOCTYPE spec PUBLIC "-//HST//DTD Specification::19990423//EN" "xmlspec-19990429.dtd" [
   <!ENTITY % versionEntities SYSTEM "versionInfo.ent">
   %versionEntities; <!-- get path and date entities -->
   <!ENTITY SchemaWG "<loc
href='http://www.w3.org/XML/Activity#schema-wg'>W3C XML Schema Working
Group</loc>">
   <!ENTITY XSP1 "<emph>XML Schema: Structures</emph>">
   <!ENTITY XSP2 "<emph>XML Schemas: Datatypes</emph>">
   <!ENTITY doc.date "&draft.day; &draft.month; &draft.year;">
   <!ENTITY w3c.doc.date "&draft.day;-&draft.month;-&draft.year;">
   <!ENTITY iso.doc.date "&draft.YY;&draft.MM;&draft.DD;">
   <!ENTITY XSP1.version "0.8">
   <!ENTITY doc.audience "WG-internal review.">
   <!ENTITY doc.distribution "Schema IG">

   <!ENTITY eacute "&#233;" > <!-- small e, acute accent -->

 ]>
<spec>
  <header>
    <title>XML Schema Part 1: Structures</title>
    <version>&XSP1.version;</version>
    <w3c-designation>&WD-XSP1;-&iso.doc.date;</w3c-designation>
    <w3c-doctype>W3C Working Draft</w3c-doctype>
    <pubdate>
      <day>&draft.day;</day>
      <month>&draft.month;</month>
      <year>&draft.year;<!-- (Point release id: <code>$Id: structures.xml,v 1.45.1.6 1999/12/17 16:14:53 ht Exp $</code>)--></year>
    </pubdate>
    <notice role="publoc"><ednote><edtext>The following SHOULD be in the publoc, but
the DTD doesn't currently allow it: the stylesheet fakes it.</edtext></ednote>
     <p>(in <loc href="&XSP1.URI;.xml">XML</loc> (with its own <loc href="&XSP1.base;/xmlspec-19990429.dtd">DTD</loc>, <loc href="&XSP1.base;/xmlschema.xsl">XSL
stylesheet</loc> (Nov REC version)
and <loc href="&XSP1.base;/xmlschema.msxsl">IE5 stylesheet</loc> (XSL as supported by version 5 of
Microsoft's Internet Explorer)) and <loc href="&XSP1.URI;.html">HTML</loc>, with separate provision of the <loc href="&XSP1.URI;.xsd">schema</loc> and <loc href="&XSP1.URI;.dtd">DTD</loc> for schemas described herein.</p>
</notice>
    <publoc> <loc href="&XSP1.base;/">&XSP1.base;/</loc> </publoc>
   <latestloc><loc href="http://www.w3.org/TR/xmlschema-1/">http://www.w3.org/TR/xmlschema-1/</loc>   
 </latestloc>   
   <prevlocs>
    <loc href="http://www.w3.org/TR/1999/WD-xmlschema-1-19991105/">http://www.w3.org/TR/1999/WD-xmlschema-1-19991105/</loc>
    <loc href="http://www.w3.org/TR/1999/WD-xmlschema-1-19990924/">http://www.w3.org/TR/1999/WD-xmlschema-1-19990924/</loc>
     <loc href="http://www.w3.org/1999/05/06-xmlschema-1/">http://www.w3.org/1999/05/06-xmlschema-1/</loc>
    </prevlocs>
    <authlist>
      <author>
        <name>Henry S. Thompson</name>
        <affiliation>University of Edinburgh</affiliation>
        <email href="mailto:ht@cogsci.ed.ac.uk">ht@cogsci.ed.ac.uk</email>
      </author>
     <author>
      <name>David Beech</name>
      <affiliation>Oracle Corp.</affiliation>
      <email href="mailto:dbeech@us.oracle.com">dbeech@us.oracle.com</email>
     </author>
     <author>
      <name>Murray Maloney</name>
      <affiliation>Commerce One</affiliation>
      <email href="mailto:murray@muzmo.com">murray@muzmo.com</email>
     </author>
     <author>
      <name>Noah Mendelsohn</name>
      <affiliation>Lotus Development Corporation</affiliation>
      <email href="mailto:Noah_Mendelsohn@lotus.com">Noah_Mendelsohn@lotus.com</email>
     </author>
    </authlist>
    <status>
<p>This is a public working draft of XML Schema 1.0 for review by the
public and by members of the World Wide Web Consortium.
</p><p>
It has been reviewed by the XML Schema Working Group, and the Working
Group has agreed to its publication.  The WG believes this draft to be
`feature-complete': the functionality included here is substantially
complete and is expected to be stable.  We do not expect to add major
new functionality, or to make major changes to the functionality
described in this draft.  Some sections of the draft (in particular
those on conformance), and some aspects of the design (in particular
details of the transfer syntax for schemas), on the other hand, are
still rough and are expected to be revised.
</p><p>
The WG expects to spend January, 2000, working out details, clarifying
points of uncertainty that arise in the review of this draft, cleaning
up inconsistencies, reviewing the design of the concrete transfer
syntax, and making editorial improvements.
</p><p>
Following that period of review and polishing, it is the WG's intent
to issue a Last Call for Review by other W3C working groups sometime
during February, 2000, and to submit this specification in March,
2000, for publication as a Candidate Recommendation.  This schedule
may vary, depending on the comments of the public and of other W3C
working groups on this draft.  Such comments are instrumental in the
WG's deliberations, and we encourage readers to review the draft and send comments to
        <loc
         href="http://lists.w3.org/Archives/Public/www-xml-schema-comments/">www-xml-schema-comments@w3.org</loc>
(<loc href='http://lists.w3.org/Archives/Public/www-xml-schema-comments/'>archive</loc>).   
</p><p>
Although the Working Group does not anticipate further substantial
changes to the functionality described here, this is still a working
draft, subject to change based on experience and on comment by the
public and other W3C working groups.  The present version should
be implemented only by those interested in providing a check on
its design or by those preparing for an implementation of the
Candidate Recommendation.  <emph>The Schema WG will not
allow early implementation to constrain its ability to make changes to
this specification prior to final release.</emph>
</p>
      <p>A list of current W3C working drafts can be found at
        <loc href="http://www.w3.org/TR/">http://www.w3.org/TR/</loc>. They may be
        updated, replaced, or obsoleted by other documents at any time. It is
        inappropriate to use W3C Working Drafts as reference material or to cite them
        as other than "work in progress". </p>
    </status>
    <abstract>
      <p><emph> XML Schema: Structures</emph> is part 1 of a two-part draft
        of the specification for the XML Schema definition language. This document
        proposes facilities for describing the structure and constraining the contents
        of XML 1.0 documents. The schema language, which is itself represented in XML
        1.0, provides a superset of the capabilities found in XML 1.0 document type
        definitions (DTDs).</p>
    </abstract>
    <pubstmt>
      <p>Boston, Mountain View, Toronto, et al.: World-Wide Web Consortium, XML
        Working Group, 1999.</p>
    </pubstmt>
    <sourcedesc>
      <p>Created in electronic form using XML.</p>
    </sourcedesc>
    <langusage>
      <language id="EN">English</language>
      <language id="ebnf">Extended Backus-Naur Form (formal grammar)
      </language>
      <language>Extensible Markup Language (XML)</language> </langusage>
    <revisiondesc>
      <slist>
       <sitem>1999-09-05: HST: Abandoned this method of logging
changes:  see CVS change log at the end of the document</sitem>
       <sitem>1999-09-02: HST: Marked non-status-quo sections as such.</sitem>
       <sitem>1999-09-01: HST: incorporated Section 2 examples from 'Simple',
modified to include some attributes.  Massaged explanatory text.</sitem>
       <sitem>1999-08-22: HST: incorporated 'Simple' section 3 changes and started to smooth over
the joints.</sitem>
       <sitem>1999-07-18: DB: updated definition of "Schema" following WG and IG email discussion.
         Changed "Schemata" to "Schemas" except where directly quoted from Requirements doc.
         Clarified in 2.5 that elements and attributes have separate symbol spaces (public comment).
         Fixed assorted typos.
       </sitem>
       <sitem>1999-06-23: HST: pushed &amp; down to lowest level, fixed incoherent
validity definition in 6.2.3.7 to agree with the note which follows.  Wrapped validation
text from 3.4 in appropriately named div4's.</sitem>
       <sitem>1999-06-20: HST: stripped out validation</sitem>
        <sitem>1999-05-03: MCM: Updated schema and DTD. Package and test.
        </sitem>
        <sitem>1999-05-03 Integration of final editors' concerns for WD1.
          Includes HT work on constraints.</sitem>
        <sitem>1999-05-02 NRM General cleanup of first few chapters. Remove
          chapter 4 redundancy (tuple discussion) with new validity rules. </sitem>
        <sitem>1999-05-02: HST: still chipping away at validity. Redefined the
          XSDL/XDTL entities.</sitem>
        <sitem>19940502: MCM: mostly annotating the schema. Also moved info
          about abstract grammar into Chapter 2. Chapter 3 now starts right into defining
          a schema. Edited text entities to make them easier to manage.</sitem>
        <sitem>19940501: HST: various</sitem>
        <sitem>1999-04-30: NRM : revisions to chapter 4</sitem>
        <sitem>1999-04-28: DB (pp HST) : promised edits for improved
          consistency and definition of 'schema'; suggested modifications to
          3.4.9/10 and 3.5 </sitem>
        <sitem>1999-04-39: HST : integrated DB's edits, completely rewrote
          6.1, replaced virtually all &lt;B&gt; with correct &lt;...ref&gt; </sitem>
        <sitem>1999-04-28: DB (pp HST) : promised edits for improved
          consistency and definition of 'schema'; suggested modifications to
          3.4.9/10 and 3.5 </sitem>
        <sitem>1999-04-23: HST : Got all productions sorted using
          'nt' and correct IDs.</sitem>
        <sitem>1999-04-21 : HST : Added lots of IDs and constraint heads:
          Validates w/o error</sitem>
        <sitem>1999-04-21 : HST : Converted with no content changes to speak of
          from MCM-XSDL-19990416.html. This version has only ID/IDREF related errors
          left.</sitem>
      </slist>
    </revisiondesc>
  </header>
  <body>
    <div1 id="intro">
      <head>Introduction</head>
      <p>This document sets out the structural part (&XSP1;) of the XML Schema definition language.</p>
      <p>Chapter 2 presents a <specref ref="concepts"/> for &XSP1;, including
        an introduction to schema constraints, types, schema composition, and symbol
        spaces. The abstract and concrete syntax of &XSP1; are introduced, along with
        other terminology used throughout the specification. </p>
      <p>Chapter 3 <specref ref="declare"/> reconstructs the core functionality
of XML 1.0, plus a number of extensions, in line with our stated requirements
<bibref ref="ref-xsreq"/>. This chapter discusses the declaration and use of
simple and complex types, elements, content models, attributes, attribute
groups, model groups and inheritance.</p>
      <p>Chapter 4 presents <specref ref="composition"/>, including the
        validation of namespace qualified instance documents, import and inclusion of declarations and definitions, access to schemas, and
        the foundations of schema-validity.</p>
      <p>Chapter 5 describes provision for including documentation in the
        definition of a schema.</p>
      <p>Chapter 6 discusses <specref ref="conformance"/>, including the rules
        by which instance documents are validated, and responsibilities of schema-aware
        processors. </p>
      <p>The normative addenda include a <specref ref="normative-schemaDTD"/>
        and a <specref ref="normative-schemaSchema"/>, which is an XML Schema schema
        for &XSP1;, a <specref ref="normative-glossary"/> [not yet written] and
        <specref ref="normative-references"/>. Non-normative appendixes include a
        <specref ref="sampleSchema"/> and <specref ref="acknowledgments"/>. </p>
      <div2 id="intro-docConventions">
        <head>Documentation Conventions</head>
        <p>This Working Draft document was produced using an
          <bibref ref="ref-xml"/> DTD and an <bibref ref="ref-xsl"/> stylesheet.</p>
        <p>The following highlighting is used to present technical material in
          this document: </p>
        <p> <termdef id="key-sampledef" term="term">A <term>term</term> is
          something we use a lot</termdef>. </p>

        <scrap lang="ebnf" id="example">

          <head>Sample Abstract Syntax Production</head>
          <prod id="nt-left" role="prefig">
            <lhs>left</lhs>
            <rhs>right1 right2</rhs>
          </prod>

        </scrap>

        <note role="example">
          <p>A non-normative example illustrating use of the schema language,
            or a related instance. </p>
          <eg xml:space="preserve">&lt;schema name="http://www.muzmo.com/XMLSchema/1.0/mySchema" &gt;</eg>
          <p>And an explanation of the example.</p>
      </note>
      <p>The following highlighting is used for non-normative commentary in
        this document:</p>
      <issue id="dummy">
        <p>A recorded issue.</p>
      </issue>

      <ednote>
        <edtext>Notes from the editors to themselves or the Working Gorup.</edtext>
      </ednote>

      <note>
        <p>General comments directed to all readers. </p>
      </note>
    </div2>
    <div2 id="intro-purpose">
      <head>Purpose</head>
      <p>The purpose of &XSP1; is to provide an inventory of XML markup
        constructs with which to write schemas. </p>
      <p>The purpose of an &XSP1; schema is to define and describe a class of
        XML documents by using these constructs to constrain and document the meaning,
        usage and relationships of their constituent parts: datatypes, elements and
        their content, attributes and their values. Schema constructs may also provide for the specification of additional
        information such as default values. Schemas are intended to document their own
        meaning, usage, and function through a common documentation vocabulary. Thus, &XSP1; can be used to define, describe and catalogue XML
        vocabularies for classes of XML documents. </p>
      
     <p>Any application that consumes well-formed XML can use the &XSP1;
        formalism to express syntactic, structural and value constraints applicable to
        its document instances. The &XSP1; formalism will allow a useful level of
        constraint checking to be described and validated for a wide spectrum of XML
        applications.  However, the language defined by this specification does not attempt to provide
        <emph>all</emph> the facilities that might be needed by <emph>any</emph>
        application. Some applications may require constraint capabilities not
        expressible in this language, and so may need to perform their own additional
        validations.</p>
    </div2>
    <div2 id="intro-relatedWork">
      <head>Relationship To Other Work</head>
      <p>The definition of &XSP1; is a part of the
        <loc href="http://www.w3.org/XML/Activity.html">W3C XML Activity</loc>. It is
        in various ways related to other ongoing parts of that Activity and other W3C
        WGs </p>
      <glist>
        <gitem>
          <label>XML Schema: Datatypes</label>
          <def>
            <p>&XSP1; has a dependency on the mechanisms for defining simple types provided in
              its companion <bibref ref="ref-xsp2"/>, published simultaneously with this
              document.   Together these two documents constitute the XML
Schema Recommendation.</p>
          </def>
        </gitem>
        <gitem>
          <label>Document Object Model </label>
          <def>
            <p>&XSP1; has not yet identified requirements or dependencies. </p>

          </def>
        </gitem>
        <gitem>
          <label>HTML </label>
          <def>
            <p>&XSP1; has been requested to support modularization of (X)HTML. </p>

          </def>
        </gitem>
        <gitem>
          <label>Internationalization Working Group </label>
          <def>
             <p>See
               <loc href="http://www.w3.org/XML/Group/1999/03/xml-schema-i18n-notes">http://www.w3.org/XML/Group/1999/03/xml-schema-i18n-notes
                (W3C Member only)</loc> </p>
          </def>
        </gitem>
        <gitem>
          <label>RDF Schema </label>
          <def>
            <p>&XSP1; has not yet documented requirements or dependencies.  See
<bibref ref="bib-camb-comm"/> for a clarification of the relationship between
the two, which includes requirements arising from web architecture considerations.</p>
          </def>
        </gitem>
        <gitem>
          <label>WAI </label>
          <def>
            <p>&XSP1; has a requirement to support accessibility. </p>
          </def>
        </gitem>
        <gitem>
          <label>XML Information Set </label>
          <def>
            <p>&XSP1; has significant dependencies on
              <bibref ref="ref-xmlinfo"/>.</p>
            <p>&XSP1; defines its own <termref def="gloss-sic">Information Set
              Contributions</termref> which are compatible with <bibref ref="ref-xmlinfo"/> although not defined as such therein.</p>
          </def>
        </gitem>
        <gitem>
          <label>XML Linking WG </label>
          <def>
            <p><specref ref="declare-key"/> uses XPath expressions, as defined
in <bibref ref="bib-xpath"/>. </p>

          </def>
        </gitem>
        <gitem>
          <label>XML Syntax </label>
          <def>
            <p>&XSP1; must interoperate with XML 1.0 and subsequent revisions.
            </p>
          </def>
        </gitem>
        <gitem>
          <label>XSL WG</label>
          <def>
            <p>The XSL Working Group has requested &XSP1; to support dimensions and aggregate
              datatypes: not discharged in this WD.</p>
          </def>
        </gitem>
      </glist>
    </div2>
    <div2 id="intro-terminology">
      <head>Terminology</head>
      <p>The terminology used to describe &XSP1; is defined in the body of this
        specification. The terms defined in the following list are used in building
        those definitions and in describing the actions of &XSP1; processors: </p>
      <glist>
        <gitem>
          <label><termdef id="key-may" term="may"><term>may</term></termdef>
          </label>
          <def>
            <p>Conforming documents and processors are permitted to but need
              not behave as described. </p>
          </def>
        </gitem>
        <gitem>
          <label><termdef id="key-must" term="must"><term>must</term></termdef>
            </label>
          <def>
            <p>Conforming documents and processors are required to behave as
              described; otherwise they are in <termref def="key-error">error</termref>. </p>

          </def>
        </gitem>
        <gitem>
          <label><termdef id="key-error" term="error"><term>error</term></termdef> </label>
          <def>
            <p>A violation of the rules of this specification; results are
              undefined. Conforming software may detect and report an error and may recover
              from it. </p>
          </def>
        </gitem>
        <gitem>
          <label><termdef id="key-fatalError" term="fatal error"><term>fatal
            error</term></termdef> </label>
          <def>
            <p>An <termref def="key-error">error</termref> which a conforming
              processor must detect and report to the application. </p>
          </def>
        </gitem>
        <gitem>
          <label><termdef id="key-match" term="match"><term>match</term></termdef> </label>
          <def>
            <p>(Of strings or names:) Two strings or names being compared must
              be character for character the same. </p>
          </def>
        </gitem>
        <gitem>
          <label><termdef id="key-identical" term="identical">identical</termdef></label>
          <def>
            <p>(Of <pt>URI</pt>s)
              <emph>identical</emph>, according to the rules for identity in
              <bibref ref="ref-xml-namespaces"/>.</p>
          </def>
        </gitem>
      </glist>
    </div2>
  </div1>
  <div1 id="concepts">
    <head>Conceptual Framework</head>
    <p> This specification uses a number of terms that are common to many of
      the fields of endeavor that have influenced the development of XML Schema.
      Unfortunately, it is often the case that these terms do not have the same
      definitions in all of those fields. This section attempts to provide
      definitions of terms as they are used to describe the conceptual framework, and
      the remainder of the specification.</p>
    <div2 id="concepts-kindsOfDocs">
      <head>Kinds of XML Documents</head>
      <p>Since XML schemas are themselves specified as XML documents or elements within documents, it is
        useful to clarify the relationships between certain kinds of XML documents and elements:
      </p>
      <glist>
        <gitem>
          <label><termdef id="key-instance" term="Instance"><term>Instance</term></termdef> </label>
          <def>
            <p>An XML element information item which conforms to some schema.
See <bibref ref="ref-xmlinfo"/> for a discussion of information items:  in
brief, <termdef term="element information item" id="eltInfoItem">an
<term>element information item</term> is the component of an infoset which
corresponds to an element.  From it other information items are accessible,
including attributes, namespace declarations and content.</termdef>
See <specref ref="composition-instances"/> and
<specref ref="conformance-schemaValidity"/> for the means by which an instance
identifies the schema(s) to which it conforms. Note we will often speak loosely
about an (XML) instance document, but this is just shorthand for the <emph>element
information item associated with the document element of an XML
document</emph>.  Similarly, we will often speak of elements when we mean
<emph>element information item</emph>.</p>
          </def>
        </gitem>
        <gitem>
          <label><termdef id="key-schema" term="Schema"><term>XML Schema</term></termdef> </label>
          <def>
            <p>An XML element information item which, along with its descendants, satisfies all the 
              Constraints on Schemas in this specification.  An XML Schema establishes a set of rules
              for constraining the structure and articulating the information
set of XML document instances.</p>
          </def>
        </gitem>
      </glist>
      <p>Note that it is possible to specify a schema to which
        schemas themselves must conform, and this is given in
        <specref ref="normative-schemaSchema"/>. An XML 1.0 DTD to which schemas
        must conform is also provided in
        <specref ref="normative-schemaDTD"/>. </p>
    </div2>
    <div2 id="concepts-schemaConstraints">
      <head>On schemas, constraints and contributions</head>
      <p>The <bibref ref="ref-xml"/> specification describes two kinds of
        constraints on XML documents: <emph>well-formedness</emph> and
        <emph>validity</emph> constraints. Informally, the well-formedness constraints
        are those imposed by the definition of XML itself (such as the rules for the
        use of the &lt; and &gt; characters and the rules for proper nesting of
        elements), while validity constraints are the further constraints on document
        structure provided by a particular DTD. </p>
      <p>Three kinds of normative statements about the impact of &XSP1;
        components on instances are distinguished in this specification:</p>
      <glist>
        <gitem>
          <label><termdef id="gloss-cos" term="Constraint on Schemas"><term>Constraint on Schemas</term></termdef>
          </label>
          <def>
            <p>Constraints on the form and content of schemas themselves, above
              and beyond those expressed in <specref ref="normative-schemaSchema"/>; </p>
          </def>
        </gitem>
        <gitem>
          <label><termdef id="gloss-svc" term="Schema-Validity Constraint"><term>Schema-Validity
            Constraint</term></termdef> </label>
          <def>
            <p>Constraints on the form and content of instances, which the instances must satisfy to
              be <termref def="key-schema-valid">schema-valid</termref>; </p>
          </def>
        </gitem>
        <gitem>
          <label><termdef id="gloss-sic" term="Schema Information Set Contribution"><term>Schema Information Set
            Contribution </term></termdef></label>
          <def>
            <p>Augmentations to post-validation information sets which follow
              as a consequence of schema-validation. </p>
          </def>
        </gitem>
      </glist>
      <note>
        <p><termref def="gloss-sic">Schema Information Set
          Contribution</termref>s are not as new as might at first appear: XML 1.0
          validation augments the XML 1.0 information set in similar ways, e.g. by
          providing values for attributes not present in instances, and by implicitly
          exploiting type information for normalization or access, e.g. consider the
          effect of <code>NMTOKENS</code> on attribute whitespace, and the semantics of
          <code>ID</code> and <code>IDREF</code>. By including <termref def="gloss-sic">Schema Information Set Contribution</termref>s, we are trying
          to make explicit something XML 1.0 left implicit.</p>
      </note>
      <p>&XSP1; not only reconstructs the DTD constraints of XML 1.0 using XML
instance syntax, it also adds the ability to define new kinds of constraints.
For example, although the author of an XML 1.0 DTD may declare an element type
as containing character data, elements, or mixed content, there is no mechanism
with which to constrain the contents of elements to only character data of a
particular form, such as only numeral sequences representing integers in a
specified range.</p>
      <p>This specification supports the expression of just such constraints by
        including in the mechanism for the declaration of elements the option of
        specifying that its contents must consist of a valid string expression of a
        particular datatype. A number of other mechanisms are added which improve the
        expressive power, usability and maintainability of schemas as a means to
        defining the structure of XML documents. </p>
    </div2>
    <div2 id="concepts-types">
     <head>Schemas, Types and Elements</head>
 <p>The purpose of a schema is to identify a set of components for use in XML documents
and to provide the rules for their correct combination.
 </p>
 <p>
The schema language itself defines an XML form for itself in terms of elements and attributes. We will describe these, and show how they are used. But first, a quick example of an XML document.
</p>
<note role="example"><eg xml:space="preserve"><![CDATA[<?xml version='1.0'?>
<PurchaseOrder orderDate="1999-05-20" xmlns="http://www.myco.com/MYPO">
    <shipTo type="US">
        <name>Alice Smith</name>
        <street>123 Maple Street</street>
        <city>Mill Valley</city>
        <state>CA</state>
        <zip>90952</zip>
    </shipTo>
    <shipDate>1999-05-25</shipDate>
    <comment>Get these things to me in a hurry, my lawn is going wild!</comment>
    <Items>
        <Item pno="333-333">
            <productName>Lawnmower, model BUZZ-1</productName>
            <quantity>1</quantity>
            <price>148.95</price>
            <comment>Please confirm this is the electric model</comment>
        </Item>
        <Item pno="444-444">
            <productName>Baby Monitor, model SNOOZE-2</productName>
            <quantity>1</quantity>
            <price>39.98</price>
        </Item>
    </Items>
</PurchaseOrder>]]></eg></note>
 <p>The purchase order consists of a main element with several subordinate
elements. Most of the subelements have simple atomic types such as <code>string</code> or
<code>date</code>, drawn from the repertoire of built-in simple types defined in <bibref ref="ref-xsp2"/>, but some are complex. We use the <code>type</code> element
when declaring elements which allow elements in their content and/or may carry attributes. For example, we can define a type called <code>Address</code> as follows:
</p>
 <note role="example"><eg xml:space="preserve"><![CDATA[<type name="Address" >
    <element name="name"   type="string" />
    <element name="street" type="string" />
    <element name="city"   type="string" />
    <element name="state"  type="string" />
    <element name="zip"    type="integer" />
    <attribute name="type" type="string" />
</type>]]></eg><p>The consequence of this definition is that an element whose 
type is declared to be <code>Address</code>
must consist of five elements and may have one attribute. Though
each has a distinct name, four of the elements and the attribute will simply contain a string in
a document instance while one will contain an integer.
</p></note>
     <p>If we're going to use the same element in a number of places, we can
declare it once and refer to it by name elsewhere:</p>
     <note role="example">
      <eg xml:space="preserve"><![CDATA[<element name="comment" type="string" />]]></eg>
      <p>This declaration restricts the <code>comment</code> element to text
content and no attributes.</p>
     </note>
  <p>
We can define a <code>PurchaseOrderType</code> for our
<code>PurchaseOrder</code> element, referring to the definitions of <code>Address</code> and <code>comment</code> as above, as:
</p>
 <note role="example"><eg xml:space="preserve"><![CDATA[<type name="PurchaseOrderType">
    <element name="shipTo"    type="po:Address" />
    <element name="shipDate"  type="date" />
    <element ref="po:comment" minOccurs="0" />
    <element name="Items"     type="po:Items" />
    <attribute name="orderDate" type="date" />
</type>]]></eg><p>The <code>shipDate</code> element daughter of
<code>PurchaseOrderType</code> is declared
above as having a simple type, as in the
<code>Address</code> example above.  The <code>comment</code> daughter is
declared by reference to a global element declaration.  Since this definition is in the
namespace being defined, and apparently the default namespace is being used for
the schema elements themselves (e.g. <code>element</code>,
<code>attribute</code>), we use a prefix (<code>po</code>) on this reference
which would have to be declared with the same URI as the target namespace URI
for the containing schema.  Similarly, the <code>shipTo</code>
and <code>Items</code> daughters are declared as having complex types which must be
defined elsewhere in the current schema.   The <code>comment</code> daughter and the
<code>orderDate</code> attribute are optional, the others are obligatory.
</p>
</note>
 <issue id="type-decl-syntax">
  <p>Further integration of the concrete syntax for type definitions is
desireable, e.g. by using 'type' for both simple and complex types, but the details of a consistent and clear way to do this
have not yet been agreed.</p></issue>

<p>Since an element declaration's <code>type</code> can identify either a
simple or a complex type, and there are separate symbol spaces for these two, the
possibility of ambiguity arises.  This is resolved in favour of the complex
type, e.g. even if a simple type called <code>Address</code> existed (either
builtin or user-defined), the above declaration for <code>shipTo</code> would
refer to the user-defined complex type of that name.</p> 
     <issue id="note-two-sses">
      <p>The separation of the simple and complex type name symbol spaces is
primarily motivated by the decision to allow unqualified reference to the <emph>ab
initio</emph> and built-in simple types.  Should this decision be reversed, as was
suggested in the report of the simplification Task Force, then the unification of the
two symbol spaces could proceed with minimal negative impact.  The potential for
error which arises from unexpected shadowing of an old simple type by a new
complex type would be removed.</p>
     </issue>
 <p>
<termdef term="definition" id="nt-definition">A <term>definition</term> creates a new type</termdef>; <termdef id="nt-declaration" term="declaration">a <term>declaration</term> enables the appearance in a
document instance of an element or attribute with a specific name and type</termdef>. In the schema,
we see both the definition of several types, and also several elements and
attributes declared
as usages of these types. For example, <code>Address</code> is defined to be a
type, while within the definition of <code>Address</code> we see five
declarations of elements and one attribute declaration. These declarations are
not themselves types, but rather an association between a name and constraints
which govern the appearance of that name in documents governed by the containing schema.</p>
 <p>
In the case of attribute declarations, the constraints are on the allowed
value, always by reference to a simple type:
</p>
 <note role="example">
<eg xml:space="preserve"><![CDATA[<attribute name="orderDate" type="date" />]]></eg>
</note>
 <p>In the case of element declarations, the constraints are on the allowed
content and attributes, by reference to a complex <emph>or</emph> a simple type (in which
case no attributes are allowed):
</p>
 <note role="example"><eg xml:space="preserve"><![CDATA[<element name="shipTo" type="po:Address" />
<element name="comment" type="string" />
]]></eg><p>Because <code>Address</code> is defined in the schema to have
certain elements as its content and to allow a certain attribute, any
<code>shipTo</code> element appearing in an instance must include those
elements and may have that attribute, while any <code>comment</code> element
may not have
any attributes, but any text content.</p></note>
 <p>As well as naming a type in an attribute or element
declaration, we can embed the type definition immediately within the
element declaration:</p>
     <note role="example">
      <eg xml:space="preserve"><![CDATA[<type name="Items">
 <element name="Item" minOccurs="0" maxOccurs="*">
  <type>
   <element name="productName" type="string" />
   <element name="quantity">
    <datatype source="integer">
     <minExclusive value="0"/>
    </datatype>
   </element>
   <element name="price" type="decimal" />
   <element ref="po:comment" minOccurs="0" />
   <attribute name="pno" type="string"/>
  </type>
 </element>
</type>]]></eg>
      <p>Here not only is the type of the <code>Item</code> element given
in line, but also the simple type of its
<code>quantity</code> daughter (the built-in simple type <code>integer</code>) is qualified inline by adding a subrange constraint.</p>
     </note>
   <p>Taken together the examples above constitute a complete schema for the
initial <code>PurchaseOrder</code> example instance.  They are drawn together
in a single complete schema in <specref ref="sampleSchema"/>.</p>
     
    </div2>
    <div2 id="concepts-schemaComponents">
      <head>Schemas and their component parts</head>
<p><termdef id="key-component" term="schema component">Schemas are composed of: <term>schema components</term>: a set of type
definitions, attribute group definitions, model group definitions, element
declarations, and attribute declarations</termdef>. Note that it is the
abstract idea of a component we are talking about here, along with its name:
an XML element such as <code>&lt;element&gt;</code> is a standardized representation
for a component, not the component itself.</p>
      <p>The next chapter <specref ref="declare"/> sets out the &XSP1; approach
        to schemas, with formal definitions of their component parts and
presentations of standardized representations for each of them. Here we informally
        summarize the key constructs used in defining schemas. A 'Yes' in the
        'Name appears in instances?' column indicates that the name will appear in instances --
        other names are for schema use only. </p>
      <table border="solid" cellpadding="5" cellspacing="0" width="100%">
        <tbody>
          <tr>
            <th align="left" valign="top" rowspan="1" colspan="1"> &XSP1;
              Feature </th>
            <th align="left" valign="top" rowspan="1" colspan="1"> Purpose
            </th>
            <th align="left" valign="top" rowspan="1" colspan="1"> Named? </th>
           <th align="left" valign="top" rowspan="1" colspan="1">Name appears
in instances?</th>

          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="declare-schema"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> A wrapper element
              containing all the definitions and declarations comprising a schema.
            </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Yes </td>
           <td valign="top">No</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="declare-datatype"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> A simple atomic type
              (content constraint), such as 'integer', that applies to character
              data in an instance document, whether it appears as an attribute value or the
              contents of an element. The mechanisms for defining simple types are set out
              elsewhere, in &XSP2;. </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Yes </td>
           <td valign="top">No</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="declare-type"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> A complete
              set of constraints for elements in instance documents, applying to both
              contents and attributes. </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Yes </td>
           <td valign="top">No</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1">
              <specref ref="declare-element"/></td>
            <td align="left" valign="top" rowspan="1" colspan="1"> An
              association between a name for an element and a type. An element
              declaration for 'A' is comparable to a DTD declaration
              <code>&lt;!ELEMENT A .....&gt;</code>.</td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Yes (local
              or global) </td>
           <td valign="top">Yes</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="declare-attribute"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> An
              association between a name for an attribute and a simple type. The
              association is local to its surrounding type.</td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Yes (local)
              </td>
           <td valign="top">Yes</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"> Content type
              </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Either a
              simple type or a content model. A content type applies to the contents of elements
              in an instance document (but not their attribute values). It provides a
              unifying abstraction for the constraints which apply to the contents of
              elements, but introduces no additional features. </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> No </td>
           <td valign="top">No</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="declare-contentModel"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> A
constraint that applies to the contents of elements in an instance
              document. May include specifications of grouping and sequencing.</td>
            <td align="left" valign="top" rowspan="1" colspan="1"> No </td>
           <td valign="top">No</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1">
              <specref ref="declare-attributeGroup"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> An
              association between a name and a reusable collection of attribute declarations.
              </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Yes </td>
           <td valign="top">No</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="declare-refinement"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> One
              type may be defined as based on another type, acquiring
              content type and/or attributes therefrom.</td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Yes </td>
           <td valign="top">No</td>
          </tr>
          <tr>
            <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="composition-schemaImport"/> </td>
            <td align="left" valign="top" rowspan="1" colspan="1"> Integrates
              definitions and/or declarations from elsewhere into the schema being
              defined, as if they had been defined locally.</td>
            <td align="left" valign="top" rowspan="1" colspan="1"> No </td>
           <td valign="top">No</td>
          </tr>
         <tr>
          <td align="left" valign="top" rowspan="1" colspan="1"><specref ref="declare-key"/> </td>
          <td align="left" valign="top" rowspan="1" colspan="1">Provide more
powerful uniqueness and intra-document reference mechanisms </td>
          <td align="left" valign="top" rowspan="1" colspan="1"> Yes </td>
           <td valign="top">No</td>
         </tr>
        </tbody>
      </table>
    </div2>
    <div2 id="concepts-nameSymbolSpaces">
      <head>Names and Symbol Spaces</head>
      <p>As indicated in the third column of the tables above, most of the
        components listed have names, which provide for references within the
        schema, and sometimes from one schema to another. For example, an attribute
        declaration can refer to a named type, such as 'integer'. A
        content model can refer to an element, and so on. </p>
      <p>If all such names were assigned from the same 'pool', then
        it would be impossible to have e.g. a type named 'integer' and an
        element with the name 'integer' in the same schema.
        <termdef id="key-symbolSpace" term="symbol space">Accordingly we introduce the
        idea of a <term>symbol space</term> (avoiding 'name space' to avoid
        confusion with the term defined in <bibref ref="ref-xml-namespaces"/>).</termdef>  A <termref def="key-symbolSpace">symbol space</termref> is similar to the non-normative concept of <xtermref href="http://www.w3.org/TR/REC-xml-names/#ns-breakdown">namespace partition</xtermref> introduced in <bibref ref="ref-xml-namespaces"/>.</p>
      <p>There is a single distinct symbol space within a given schema for each
        of the abstractions named above other than 'Attribute' and
        'element': within a given symbol space, names are unique, but
        the same name may appear in more than one symbol space without conflict. In
        particular note that the same name can refer to both a type and an
        element, without conflict or necessary relation between the two. </p>
      <p>Attributes and local element declarations are special, in that
        every type defines its own attribute symbol space and local element symbol 
        space, which are distinct from each other.  In addition, top-level elements
        (whose declarations are not contained within a type definition) reside in 
        their own symbol space.
        </p>
    </div2>
   <div2 id="ref-schema">
    <head>Referencing Schema Components</head>
    <p>The names of schema components such as type definitions and element
declarations are not of type <code>ID</code>, as explained above:  they are not
unique within a schema, just within a symbol space.  This means that simple
fragment identifiers will not work to reference schema components.</p>
    <p>In the long run we expect to provide some mechanism suitable for referencing the
semantic components of schemas as such.  In the mean time, we observe that
<bibref ref="ref-xpointer"/> provides a mechanism which maps well onto our
notion of symbol spaces.  An fragment identifier of the form
<code>#xpointer(schema/element[@name="person"])</code> will uniquely identify
the element declaration with name <code>person</code>, and similar fragment
identifiers can obviously be constructed for the other top-level symbol spaces.</p>
   </div2>
<div2 id="comp-tns">
<head>Association of components with a target namespace </head>
<p>Every element and attribute declaration is associated with a target
namespace URI, or with no namespace. More specifically, each symbol space is
associated directly (in the case of global declarations) or indirectly (in the
case of local declarations) with a target namespace or with no namespace. So,
the name of each global declaration is effectively qualified by the target
namespace in which it is defined. Locally scoped element and attribute
declarations are named in a symbol space defined by their containing type
definition.</p>
<p>Global element and attribute declarations are used to validate instance
document constructs in the namespace identified by the URI of the target
namespace for the corresponding declaration. Declarations with a null target
namespace validate non-namespace qualified instance document constructs.</p>
   <div3 id="def-tns">
<head>Association of definitions with a target namespace </head>
<p>The XML namespaces recommendation discusses only instance document syntax for
elements and attributes; it therefore provides no direct framework for managing
the names of types, attribute groups, and other facilities provided by XML
schemas. Nevertheless, we apply the target namespace facility uniformly to all
schema components. Specifically, the target namespace qualifies the symbol space
for definitions as well as for declarations.</p>
</div3>
<div3 id="tns-decl">
<head>Providing a target namespace for definitions and declarations </head>
<p>The above discussion requires that each global definition and
declaration be associated with a target namespace. The standard
XML format for schema definitions provides a <code>"targetNamespace"</code> attribute for the
<code>&lt;schema&gt;</code> element. </p>
<eg xml:space="preserve">    &lt;schema targetNamespace="someNSURI"&gt;
      ...every global declaration &amp; def'n here...
      ...is in targetNamespace
    &lt;/schema&gt;
</eg>
<p>If specified, this supplies the same target namespace for all the definitions
and declarations contained within that schema element.  If absent, it indicates that all the definitions and declarations have a null target namespace.</p>
</div3>
</div2>



    <div2 id="declare-syntaxes">
      <head>Abstract and Concrete Syntax</head>
      <p>&XSP1; is presented here primarily in the form of an
        <termdef id="key-abstractSyntax" term="abstract syntax"> <term>abstract
        syntax</term>, which provides a formal specification of the information
        provided for each declaration and definition in the schema language. </termdef>
        The abstract syntax is presented using a simplified BNF. Defined terms are to
        the left. Their components are to the right, with a small amount of
        meta-syntax: ()s for grouping, | to separate alternatives, ? for optionality, *
        and + for iteration. Terms in italics are primitives, not expanded here, either
        because they are defined elsewhere (e.g. <pt>URI</pt>, defined by
        <bibref ref="ref-uri"/>) or because they can only be grounded once a concrete
        syntax is decided on (e.g. <pt>choice</pt>). </p>
      <p>An abstract syntax production prefixed with a number in brackets (e.g.
        [3]) is normative; other abstract syntax is either for purposes of explanation,
        or is a duplicate (for convenience) of a normative definition to be found
        elsewhere.</p>
      <p>The abstract syntax illustrates the expressive power of the language,
        and the relationships among its component parts. The abstract syntax can be
        used to evaluate the expressive power of &XSP1;, but not its look and feel. In
        particular, please note that neither ordering within or between productions or
        choice of names is significant, and that any particular concrete syntax is not
        constrained by these.</p>
      <p>The <termdef id="key-concreteSyntax" term="concrete syntax"><term>concrete syntax</term> of &XSP1;, the exact
        element and attribute names used in a schema</termdef>, are a key feature of
        its proposed design. The concrete syntax is the form in which the schema
        language is used by schema authors. Though its elements and attributes are
        often different from the terms of the abstract syntax BNF, the features and
        expressive power of the two are congruent. The concrete syntax profoundly
        affects the convenience and usability of the schema language. </p>
      <p>We include a preliminary concrete syntax in this draft, via examples, paradigms
        and in <specref ref="normative-schemaSchema"/> and
        <specref ref="normative-schemaDTD"/>. Unlike the previous version, in
which the intention was to
        stay quite close to the abstract syntax, in this version we have begun
to take convenience and clarity into account. </p>
    </div2>
  </div1>
  <div1 id="declare">
   <head>Schema Definitions and Declarations</head>

<ednote><edtext> possible changes to the definition of what of schema is, to
reflect a our discussion of layering.</edtext></ednote>

    <p>The principal purpose of &XSP1; is to provide a means for defining
      schemas that constrain the contents of instances and augment the
      information sets thereof. </p>
    <div2 id="declare-schema">
      <head>The Schema</head>
      <p>A schema contains some preamble information and a set of definitions
        and declarations. </p>

      <scrap lang="ebnf" id="RuleSet.XS3">

        <head>Schema top level</head>
        <prod id="nt-schema">
          <lhs>schema</lhs>
          <rhs xml:space="preserve"><nt def="nt-preamble">preamble</nt> <nt def="nt-dds">dds</nt>*
          </rhs>
        </prod>
        <prod id="nt-dds">
          <lhs>dds</lhs>
          <rhs xml:space="preserve"><nt def="nt-annotation">annotation</nt> | <nt def="nt-datatypeDefn">datatypeDefn</nt> |
            <nt def="nt-typeDefn">typeDefn</nt> | <nt def="nt-elementDecl">elementDecl</nt> | <nt def="nt-attributeGroupDefn">attributeGroupDefn</nt> | <nt def="nt-notationDecl">notationDecl</nt> | <nt def="nt-include">include</nt>| <nt def="nt-import">import</nt> | <nt def="nt-generalConstraint">generalConstraint</nt></rhs>
        </prod>
        <prod id="nt-preamble">
          <lhs>preamble</lhs>
          <rhs xml:space="preserve"><nt def="nt-xmlSchemaRef">xmlSchemaRef</nt>
<nt def="nt-targetNamespace">targetNamespace</nt> <nt def="nt-schemaVersion">schemaVersion</nt> <nt def="nt-finalDefault">finalDefault</nt>? <nt def="nt-exactDefault">exactDefault</nt>?</rhs>
        </prod>
        <prod id="nt-xmlSchemaRef">
          <lhs>xmlSchemaRef</lhs>
          <rhs xml:space="preserve"><pt>URI</pt> </rhs>
        </prod>
        <prod id="nt-targetNamespace">
          <lhs>targetNamespace</lhs>
          <rhs><pt>URI</pt></rhs>
        </prod>
        <prod id="nt-schemaVersion">
          <lhs>schemaVersion</lhs>
          <rhs xml:space="preserve"><pt>string-value</pt> </rhs>
        </prod>
       <prod id="nt-finalDefault">
<lhs>finalDefault</lhs>
<rhs xml:space="preserve"><pt>extension</pt>?
<pt>restriction</pt>?</rhs>
</prod>
       <prod id="nt-exactDefault">
<lhs>exactDefault</lhs>
<rhs xml:space="preserve"><pt>extension</pt>?
<pt>restriction</pt>? <pt>equivClass</pt>?</rhs>
</prod>
      </scrap>
      <p><nt def="nt-preamble">preamble</nt> consists of an
        <nt def="nt-xmlSchemaRef">xmlSchemaRef</nt> specifying the URI for &XSP1;; the
        <nt def="nt-targetNamespace">targetNamespace</nt> specifying the URI of
the namespace which this schema is about; and a <nt def="nt-schemaVersion">schemaVersion</nt> specification for private version
        documentation purposes and version management.</p>
     <p><nt def="nt-finalDefault">finalDefault</nt> and <nt def="nt-exactDefault">exactDefault</nt> provide defaults for <nt def="nt-final">final</nt> and <nt def="nt-exact">exact</nt> respectively for type definitions and element declarations.  The default for <emph>these</emph> properties is empty in both cases.</p>
     <p>See <specref ref="composition"/> for discussion of schemas, instances
and namespaces, and also for <nt def="nt-import">import</nt> and <nt def="nt-include">include</nt>.</p>


      <note role="example">
        <eg xml:space="preserve">
&lt;!DOCTYPE schema
          PUBLIC '-//W3C//DTD XML Schema Version 1.0//EN'
          SYSTEM '&XSP1.URI;.dtd' &gt;

&lt;schema targetNS="http://purl.org/metadata/dublin_core"
        version="M.n"
        xmlns="&XMLSchemaNS;"&gt;

  ...

&lt;/schema&gt;
</eg>
        <p>Note that the abstract syntax <nt def="nt-xmlSchemaRef">xmlSchemaRef</nt> is
          realised via a default namespace declaration in the concrete syntax.</p>
    </note>
     <p>Although the schema above is a complete XML document,  <code>schema</code>
need not be the document element, but can appear within other documents. 
Indeed there is no requirement that a schema be derived from a (text) document
at all:  it could be built 'by hand' via e.g. a DOM-conformant API.</p>
    <p>The schema's declarations and definitions, discussed in detail in
      <specref ref="declare"/>, provide for the creation of new schema components:
    </p>

    <scrap lang="ebnf" id="RuleSet.XS4">

      <head>Summary of Definitions and Declarations</head>
      <prod id="nt-datatypeDefn2" role="prefig">
        <lhs>datatypeDefn</lhs>
        <rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-datatypeSpec">datatypeSpec</nt> </rhs>

      </prod>
      <prod id="nt-typeDefn2" role="prefig">
        <lhs>typeDefn</lhs>
        <rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-typeSpec">typeSpec</nt> </rhs>
      </prod>
      <prod id="nt-elementDecl2" role="prefig">
        <lhs>elementDecl</lhs>
        <rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-elementSpec">elementSpec</nt> </rhs>
      </prod>
     <prod id="nt-attrDecl2" role="prefig">
<lhs>attribute</lhs>
<rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-attrSpec">attributeSpec</nt></rhs>
</prod>
      <prod id="nt-attributeGroupDefn2" role="prefig">
        <lhs>attributeGroupDefn</lhs>
        <rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-attrsSpec">attributesSpec</nt> </rhs>
      </prod>
      <prod id="nt-notationDecl2" role="prefig">
        <lhs>notationDecl</lhs>
        <rhs><pt>NCName</pt> <nt def="nt-notationSpec">notationSpec</nt> </rhs>
      </prod>
    </scrap>

    <note role="example">
      <p>The following illustrates the basic model for declaring or defining all &XSP1;
        components:</p>
      <eg xml:space="preserve">
 &lt;datatype name="myDatatype"&gt;
  ...
 &lt;/datatype&gt;

 &lt;type name="myType"&gt;
  ...
 &lt;/type&gt;

 &lt;element name="myElement"&gt;
  ...
 &lt;/element&gt;

 &lt;attributeGroup name="myAttrGroup"&gt;
  ...
 &lt;/attributeGroup&gt;

 &lt;group name="myModelGroup"&gt;
  ...
 &lt;/group&gt;

 &lt;notation name="myNotation" ... /&gt;

&lt;/schema&gt;
</eg>
      <p>When creating a component, we establish an association between its name
        and the specification for that component. Each new component therefore
        creates a new entry in the symbol space for that kind of component. </p>
  </note>
<ednote><edtext> make sure that discussion of targetNamespace is up-to-date.</edtext></ednote>

  <p>The <specref ref="cos-unique"/> <termref def="gloss-cos">Constraint on Schemas</termref> obtains.</p>
  <issue id="no-evolution">
    <p> This draft does not deal with the requirement "for addressing the
      evolution of schemata" (see <bibref ref="ref-xsreq"/>).</p>
  </issue>
</div2>
<div2 id="declare-documentRoot">
  <head>The Document and its Root</head>
  <note>
    <p>We have not so far seen any need to reconstruct the XML 1.0 notion of
      <emph>root</emph>. For the connection from document instances to schemas, see
<specref ref="composition-instances"/> and <specref ref="conformance-schemaValidity"/>.</p>
  </note>
</div2>
<div2 id="refSchemaConstructs">
  <head>References to Schema Constructs</head>
  <p> Uniform means are provided for reference to a broad variety of schema
    constructs, both within a single schema and to features imported (<specref ref="composition-schemaImport"/>) from external schemas. The name used to
    reference any component of &XSP1; from within a schema consists of a
    <termref def="gloss-QName">QName</termref>. In a few
    cases, some elaboration may be added to a reference: this is made clear as
    the individual reference forms are introduced below. </p>

  <scrap lang="ebnf" id="RuleSet.XS2">

    <head>Example: Component Names and References</head>
    <prod id="nt-datatypeRef2" role="prefig">
      <lhs>datatypeRef</lhs>
      <rhs xml:space="preserve"><nt def="nt-datatypeName">datatypeName</nt></rhs>
    </prod>
    <prod id="nt-datatypeName2" role="prefig">
      <lhs>datatypeName</lhs>
      <rhs xml:space="preserve"><pt>QName</pt></rhs>
    </prod>
    <prod id="nt-typeRef2" role="prefig">
      <lhs>typeRef</lhs>
      <rhs><nt def="nt-typeName">typeName</nt></rhs>
    </prod>
    <prod id="nt-typeName2" role="prefig">
      <lhs>typeName</lhs>
      <rhs xml:space="preserve"><pt>QName</pt></rhs>
    </prod>
    <prod id="nt-elementRef2" role="prefig">
      <lhs>elementRef</lhs>
      <rhs xml:space="preserve"><nt def="nt-elementName">elementName</nt> </rhs>
    </prod>
    <prod id="nt-elementName2" role="prefig">
      <lhs>elementName</lhs>
      <rhs xml:space="preserve"><pt>QName</pt></rhs>
    </prod>
    <prod id="nt-attributeGroupRef2" role="prefig">
      <lhs>attributeGroupRef</lhs>
      <rhs xml:space="preserve"><nt def="nt-attributeGroupName">attributeGroupName</nt></rhs>
    </prod>
    <prod id="nt-attributeGroupName2" role="prefig">
      <lhs>attributeGroupName</lhs>
      <rhs xml:space="preserve"><pt>QName</pt></rhs>
    </prod>
    <prod id="nt-modelGroupRef2" role="prefig">
      <lhs>modelGroupRef</lhs>
      <rhs><nt def="nt-modelGroupName">modelGroupName</nt></rhs>
    </prod>
    <prod id="nt-modelGroupName2" role="prefig">
      <lhs>modelGroupName</lhs>
      <rhs xml:space="preserve"><pt>QName</pt></rhs>
    </prod>
    <prod id="nt-notationRef2" role="prefig">
      <lhs>notationRef</lhs>
      <rhs><nt def="nt-notationName">notationName</nt></rhs>
    </prod>
    <prod id="nt-notationName2" role="prefig">
      <lhs>notationName</lhs>
      <rhs><pt>QName</pt></rhs>
    </prod>
  </scrap>

  <p>The abstract syntax above characterizes the reference mechanisms used in this
    specification.</p>
  <note role="example">
    <eg xml:space="preserve">
&lt;element name="elem1" type="Address"/&gt;

&lt;element name="elem2" type="XHTML:BLOCKQUOTE"/&gt;

&lt;attribute name="attr1"
              type="xsl:quantity"/&gt;
</eg>
    <p>The first of these is a local reference, the other two refer to schemas
      elsewhere and assume that the prefixes used have been declared and their namespaces declared for import. See <specref ref="composition-schemaImport"/> for a
      discussion of importing.</p>
</note>
<p>The <specref ref="cos-cons-import"/> <termref def="gloss-cos">Constraint on Schemas</termref> obtains.</p>
<p>The <termref def="key-identify">identify</termref> definition wrt schema-validity obtains.</p>
 <p>The
  <specref ref="cos-ident-ref"/> <termref def="gloss-cos">Constraint on
  Schemas</termref> also obtains.</p>
</div2>
<div2 id="declare-typesElementsAttributes">
<head>Types, Elements and Attributes</head>
<p>Like XML 1.0 DTDs, &XSP1; provides facilities for constraining the contents
  of elements and the values of attributes, and for augmenting the information
  set of instances, e.g. with defaulted values and type information.
<termdef id="key-typeDefn" term="type definition">We call a set of
<termref def="SC">SC</termref>s intended for use in this way a
<term>type definition</term>.</termdef></p>
<p>  <termdef id="SC" term="SC">We refer hereafter to the combination of schema
  constraints and information set contributions with the abbreviation
  <term>SC</term></termdef>. Compared to DTDs, &XSP1; provides for a richer set
  of <termref def="SC">SC</termref>s, and improved capabilities for sharing
  <termref def="SC">SC</termref>s across sets of elements and attributes.</p>
<div3 id="declare-datatype">
  <head>Simple Type Definition</head>
  <p>We start with the simple types
whose expression in XML documents consists entirely of character data.</p>

  <scrap lang="ebnf" id="RuleSet.XS5">

    <head>Simple Types</head>
    <prod id="nt-datatypeDefn">
      <lhs>simpleTypeDefn</lhs>
      <rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-datatypeSpec">simpleTypeSpec</nt> </rhs>
    </prod>
    <prod id="nt-datatypeSpec">
      <lhs>simpleTypeSpec</lhs>
      <rhs xml:space="preserve"><nt def="nt-datatypeRef">simpleTypeRef</nt> <nt def="nt-facet">facet</nt>* <nt def="nt-final">final</nt>? <pt>abstract</pt>?</rhs>
    </prod>
   <prod id="nt-facet">
  <lhs>facet</lhs>
  <rhs><com>is defined by &XSP2;.  It might be a range restriction, min/max
constraint, etc.</com></rhs>
 </prod>
    <prod id="nt-datatypeRef">
      <lhs>simpleTypeRef</lhs>
      <rhs xml:space="preserve"><nt def="nt-datatypeName">simpleTypeName</nt></rhs>
    </prod>
    <prod id="nt-datatypeName">
      <lhs>simpleTypeName</lhs>
      <rhs xml:space="preserve"><pt>QName</pt> </rhs>
    </prod>

  </scrap>

  <p>&XSP1; incorporates the simple type specification mechanisms defined by
    <bibref ref="ref-xsp2"/> in order to express <termref def="SC">SC</termref>s on
    attribute values and the contents of elements consisting entirely of character data. </p>
  <p>The production for <nt def="nt-facet">facet</nt> above serves to indicate where this
    chapter connects with &XSP2;.  The concrete syntax
displayed below is copied from <bibref ref="ref-xsp2"/>.  All facets are optional and may appear in any order
within the <code>datatype</code> element.  The <nt def="nt-datatypeRef">simpleTypeRef</nt> in the <nt def="nt-datatypeSpec">simpleTypeSpec</nt> identifies the simple type on which the
one being defined is based:  infinite regress is avoided because &XSP2;
provides a set of built-in <emph>ab initio</emph> simple types.</p>
  <p>The other productions provide for using simple types once they have been
    defined, see below under <nt def="nt-typeDefn">typeDefn</nt> and
    <nt def="nt-attrDecl">attribute</nt>.</p>
  <p>As explained in <specref ref="refSchemaConstructs"/>, the use of <termref def="gloss-QName">QName</termref> allows for the referenced
definition to be located in some other schema.</p>
 <p>An <pt>abstract</pt> type cannot itself be used as the type of an attribute
or element.</p>
 <p>A simple type definition can rule itself out as the source of type
derivations, by declaring itself <nt def="nt-final">final</nt>.</p>
  <note role="example">
    <eg xml:space="preserve"><![CDATA[<datatype name="posInt" source="integer"/>
 <minExclusive value="0"/>
</datatype>

<attribute name="foo" type="posInt"/>

<attribute name="baz" type="integer"/>

<attribute name="fontSize" type="xsl:quantity"
           fixed="12pt"/>]]></eg>
<p>The first <code>attribute</code> example references
      the definition above it. The second references a datatype pre-defined by
      &XSP2;. The third references a datatype in an (imaginary) XSL schema and fixes
      its value.</p>
</note>

 <note>
  <p>See <loc href="#type-decl-syntax">previous note on the type definition issue</loc>.</p>
 </note>

<p>The <termref def="key-satisfy-dt">satisfy-dt</termref> definition wrt schema-validity obtains.</p>
<p>The <specref ref="sic-datatype"/> <termref def="gloss-sic">Schema Information Set Contribution</termref> obtains.</p>
</div3>
<div3 id="declare-type">
<head>Complex Type Definition</head>
 <p>We now move on to <termdef id="type" term="complex type">the <term>complex type</term>s
whose expression in XML documents consists of elements with attributes and/or
element content.</termdef></p>

<scrap lang="ebnf" id="RuleSet.XS6">

  <head>Types</head>
 <prod id="nt-typeDefn">
  <lhs>complexTypeDefn</lhs>
  <rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-typeSpec">complexTypeSpec</nt></rhs>
 </prod>
  <prod id="nt-typeSpec">
    <lhs>complexTypeSpec</lhs>
    <rhs xml:space="preserve"><nt def="nt-contentType">contentType</nt> <nt def="nt-attrsSpec">attributesSpec</nt>? <nt def="nt-final">final</nt> <nt def="nt-exact">exact</nt> <pt>abstract</pt>?</rhs>
  </prod>
 <prod id="nt-attrsSpec">
  <lhs>attributesSpec</lhs>
  <rhs xml:space="preserve">( <nt def="nt-attrDecl">attribute</nt> |
      <nt def="nt-attributeGroupRef">attributeGroupRef</nt> )* <nt def="nt-anyAttr">attrWildcard</nt>?</rhs>
 </prod>
<prod id="nt-contentType2" role="prefig">
<lhs>[contentType</lhs>
<rhs xml:space="preserve"><nt def="nt-datatypeRef">simpleTypeRef</nt> | <nt def="nt-contentModel">contentModel</nt>]</rhs>
</prod>
  <prod id="nt-typeRef">
    <lhs>complexTypeRef</lhs>
    <rhs xml:space="preserve"><nt def="nt-typeName">complexTypeName</nt> </rhs>
  </prod>
  <prod id="nt-typeName">
    <lhs>complexTypeName</lhs>
    <rhs xml:space="preserve"><pt>QName</pt></rhs>
  </prod>

</scrap>

<p>The <nt def="nt-typeDefn">complexTypeDefn</nt> production and its descendants
provide for all the <termref def="SC">SC</termref>s which constitute a complex type
definition; the last two productions provide for reference to complex types once defined. But note
  that the name of a type is not <emph>ipso facto</emph> the name of
  elements whose appearance in instances will be associated with the
  <termref def="SC">SC</termref>s which constitute that type. The connection between an element
  name and a type is made by an <nt def="nt-elementDecl">elementDecl</nt>, see below. </p>
<p>Alongside <nt def="nt-attrsSpec">attributesSpec</nt> for permitted attributes,
  <termref def="SC">SC</termref>s for contents are specified by a <nt def="nt-contentType">contentType</nt>: for elements which may contain only
character data, this is a simple
type (via a <nt def="nt-datatypeRef">simpleTypeRef</nt>) or, for other kinds of
  elements, a <nt def="nt-contentModel">contentModel</nt>.  An
<pt>abstract</pt> type may not be used as the type in an <nt def="nt-elementDecl">elementDecl</nt>.  (See <specref ref="declare-openness"/> for a discussion of <nt def="nt-anyAttr">attrWildcard</nt>.  See
 <specref ref="declare-refinement"/> for the full details on <nt def="nt-contentType">contentType</nt>, of which the above is only a summary, as well as <nt def="nt-final">final</nt>, <nt def="nt-exact">exact</nt> and more on <pt>abstract</pt>.)</p>

<note role="example">
    <eg xml:space="preserve"><![CDATA[<type name="length1" type="decimal"/>
 <restrictions>
  <minInclusive value="0"/>
 </restrictions>
 <attribute name="unit" type="NMTOKEN"/>
</type>

<element name="width" type="length1"/>

  <width unit="cm">2.54</width>

<type name="length2">
 <element name="size">
  <datatype source="decimal">
   <minInclusive value="0"/>
  </datatype>
 </element>
 <element name="unit" type="NMTOKEN"/>
</type>

<element name="depth" type="length2"/>

  <depth>
   <size>2.54</size><unit>cm</unit>
  </depth>]]>
</eg>
  <p>
    Two approaches to defining a type for length:  one with
character data content constrained by a qualified reference to
    a built-in datatype, and one attribute, the other using two
elements.
</p>
</note>
<p>Note that both the <nt def="nt-datatypeRef">datatypeRef</nt> and the <nt def="nt-typeRef">typeRef</nt> options in
the abstract syntax are realised by the <code>source</code> attribute on the
<code>type</code> element.  <code>source</code> must refer to a simple type
if <code>content</code> is <code>textonly</code>.  The contents of the <code>restrictions</code>
element will be quite different in the two cases, and if the
<code>source</code> refers to a  simple type, no content model is appropriate, so none
of <code>element</code>, <code>group</code> or <code>any</code> are allowed. 
The values other than <code>textonly</code> for <code>content</code> express
choices recorded in the abstract syntax in the <nt def="nt-contentModel">contentModel</nt> and
<nt def="nt-richModel">richModel</nt> productions below.</p>
 <p>Careful consideration of the above abstract and concrete syntax reveal that
a type need consist of no more than a name, i.e. that
 <code>&lt;type name="anything"/></code> is allowed.  See the discussion of the
<termref def="term-ur-type">ur-type</termref> in <specref ref="declare-refinement"/> for what such a type means.</p>
 <note>
  <p>See <loc href="#type-decl-syntax">previous note on the type definition issue</loc>.</p>
 </note>
<p>The <specref ref="cos-attrg-unique"/> <termref def="gloss-cos">Constraint on Schemas</termref> obtains.</p>
<p>The <specref ref="cos-attrg-ided"/> <termref def="gloss-cos">Constraint on Schemas</termref> obtains.</p>
<p>The <termref def="key-attr-decl-set">attr-decl-set</termref> definition wrt schema-validity obtains.</p>
<p>The <termref def="key-attr-fullname">attr-fullname</termref> definition wrt schema-validity obtains.</p>
<p>The <specref ref="cos-attr-unique"/> <termref def="gloss-cos">Constraint on Schemas</termref> obtains.</p>
<p>The <termref def="key-satisfy-as">satisfy-as</termref> definition wrt schema-validity obtains.</p>
<p>The <specref ref="sic-type"/> <termref def="gloss-sic">Schema Information Set Contribution</termref> obtains.</p>
</div3>
<div3 id="declare-attribute">
<head>Attribute Declaration</head>
<p>Attribute declarations associate a name (which will appear as an attribute
in start tags in instances) with <termref def="SC">SC</termref>s for the
presence and value thereof by referring to a (possibly restricted) simple type.  These <termref def="SC">SC</termref>s in turn will be part of the <termref def="SC">SC</termref>s of one or more types.  A default or fixed
value may be supplied, as well as an indication of whether the attribute is
optional or required.</p>

<scrap lang="ebnf" id="RuleSet.XS7">

<head>Attributes</head>
<prod id="nt-attrDecl">
<lhs>attribute</lhs>
<rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-attrSpec">attributeSpec</nt></rhs>
</prod>
 <prod id="nt-attrSpec">
  <lhs>attributeSpec</lhs>
  <rhs xml:space="preserve"> <nt def="nt-datatypeSpec">datatypeSpec</nt>
<nt def="nt-occurs">occurs</nt> <nt def="nt-valueConstraint">valueConstraint</nt>?</rhs>
 </prod>
    <prod id="nt-valueConstraint">
      <lhs>valueConstraint</lhs>
      <rhs xml:space="preserve"><pt>default</pt> | <pt>fixed</pt> </rhs>
    </prod>
<prod id="nt-datatypeSpec2" role="prefig">
<lhs>datatypeSpec</lhs><rhs xml:space="preserve"><nt def="nt-datatypeRef">datatypeRef</nt> <nt def="nt-facet">facet</nt>*</rhs>
</prod>
 <prod id="nt-occurs2" role="prefig">
<lhs>occurs</lhs>
<rhs xml:space="preserve"><pt>minOccurs</pt> <pt>maxOccurs</pt></rhs>
</prod>
<prod id="nt-valueConstraint2" role="prefig">
<lhs>valueConstraint</lhs>
<rhs xml:space="preserve"><pt>default</pt> | <pt>fixed</pt> </rhs>
</prod>
<prod id="nt-datatypeName3" role="prefig">
<lhs>datatypeName</lhs>
<rhs xml:space="preserve"><pt>QName</pt></rhs>
</prod>

</scrap>

<note>
<p>A number of productions are
repeated here for easy reference.</p>
</note>
<p>Attribute declarations provide for: </p>
<ulist>
<item>
<p>Requiring/preventing the appearance of attributes (the need to prevent an
attribute from appearing, by giving a value of <code>0</code> to
<pt>maxOccurs</pt>, will be clarified in <specref ref="declare-refinement"/>; </p>
</item>
<item>
<p>Constraining attribute values to express a datatype;</p>
</item>
 <item>
  <p>Providing default or fixed values for an attribute.</p>
 </item>
</ulist>
<note role="example">
<eg xml:space="preserve"><![CDATA[<attribute name="myAttribute"/>

<attribute name="yetAnotherAttribute" type="integer" minOccurs="1"/>

<attribute name="anotherAttribute" default="42">
 <datatype source="integer">
  <minExclusive value="0"/>
 </datatype>
</attribute>

<attribute name="stillAnotherAttribute" type="string" fixed="Hello world!"/>]]>
</eg>
<p>Four attributes are declared: one with no explicit
<termref def="SC">SC</termref>s at all; two declared by reference to the
built-in simple datatype <code>integer</code>, one required to
be present in instances and one with a default and a subrange qualification; and one with a fixed value.</p>
</note>
 <p>The <code>type</code> attribute is used when the attribute can use a
built-in or pre-declared datatype, i.e. if no <nt def="nt-facet">facets</nt>
are part of its <nt def="nt-datatypeSpec">datatypeSpec</nt>.  Otherwise an
anonymous <code>datatype</code> is used.</p>
<p>Wherever attribute declarations are used, the surrounding
type definition provides its own symbol space for attribute names. E.g. an attribute
named <code>title</code> within one type need not have the same
<nt def="nt-datatypeRef">datatypeRef</nt> as one declared within another
type.</p>
<p>The <termref def="key-attr-satisfy">attr-satisfy</termref> definition wrt schema-validity obtains.</p>

<p>The default when no <nt def="nt-datatypeRef">datatypeRef</nt> is
provided is the <termref def="term-ur-type">ur-type</termref>, which imposes no constraints at all.</p>

<p>The <termref def="key-satisfy-attrs">satisfy-attrs</termref> definition wrt schema-validity obtains.</p>
<p>The <specref ref="sic-attr-default"/> <termref def="gloss-sic">Schema Information Set Contribution</termref> obtains.</p>
<issue id="namespace-declare">
<p>We've got a problem with namespace declarations: they're not
attributes at the infoset level, so they can appear without compromising
validity, <emph>except</emph> if there is a fixed or required declaration, and defaults
should have the apparently desired effect.  I.e., if a schema declares an
attribute whose name is <code>xmlns</code> with a default or fixed value, does
it change the infoset?  Or if we allow QNames as such to be declared, <code>xmlns:foo</code>.</p>
</issue>
</div3>
<div3 id="declare-attributeGroup">
<head>Attribute Group Definition</head>
<p>A schema can name a group of attributes so that they may be incorporated as a
whole into type definitions: </p>

<scrap lang="ebnf" id="RuleSet.XS8">

<head>Attribute groups</head>
<prod id="nt-attributeGroupDefn">
<lhs>attributeGroupDefn</lhs>
<rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-attrsSpec">attributesSpec</nt></rhs>
</prod>
 <prod id="nt-attrsSpec2" role="prefig">
  <lhs>attributesSpec</lhs>
  <rhs xml:space="preserve">( <nt def="nt-attrDecl">attribute</nt> |
      <nt def="nt-attributeGroupRef">attributeGroupRef</nt> )* <nt def="nt-anyAttr">attrWildcard</nt>?</rhs>
 </prod>
<prod id="nt-attributeGroupRef">
<lhs>attributeGroupRef</lhs>
<rhs xml:space="preserve"><nt def="nt-attributeGroupName">attributeGroupName</nt></rhs>
</prod>
<prod id="nt-attributeGroupName">
<lhs>attributeGroupName</lhs>
<rhs xml:space="preserve"><pt>QName</pt></rhs>
</prod>
</scrap>

<p>Attribute group definitions provide a construct to replace some uses of
<termref def="gloss-parameterEntity">parameter entities</termref>. 
See <specref ref="declare-openness"/> for a discussion of <nt def="nt-anyAttr">attrWildcard</nt>.</p>

<note role="example">
<eg xml:space="preserve">&lt;attributeGroup name="myAttrGroup"&gt;
    &lt;attribute .../&gt;
    ...
&lt;/attributeGroup&gt;

&lt;type name="myelement" content="empty"&gt;
    &lt;attributeGroup ref="myAttrGroup"/&gt;
&lt;/type&gt;
</eg>
<p>Define and refer to an attribute group. The effect is as if the attribute
declarations in the group were present in the type definition.</p>
</note>
 <p>The concrete syntax above is the first example of a pattern which will
recur:  The same element, in this case <code>attributeGroup</code>, serves both to
define and to incorporate by reference.  In the first case the
<code>name</code> attribute is required, in the second the <code>ref</code>
attribute is required, and the element must be empty.  These two are mutually exclusive, and also conditioned
by context:  the defining form, with a <code>name</code>, must occur at the top
level of a schema, whereas the referring form, with a <code>ref</code>, must
occur within a complex type definition or an attribute group definition.</p>
 <ednote>
<edtext>There needs to be some discussion of what happens in case of name
conflict between attrs as a result of an attr group ref.</edtext>
 </ednote>
<issue id="global-attrs">
<p>Somewhere in Chapter 3, we need to introduce a means for
declaring global attributes.</p>
</issue>
</div3>
<div3 id="declare-contentModel">
<head>Element Content Model</head>
<p>When content of elements is not constrained by reference to a simple type
(<specref ref="declare-datatype"/>), it can be unconstrained, be constrained to
have no content, or allow elements in its content, in which case the form of the content is specified in
more detail.</p>

<scrap lang="ebnf" id="RuleSet.XS9">

<head>Content model</head>
<prod id="nt-contentModel">
<lhs>contentModel</lhs>
<rhs xml:space="preserve"><pt>unconstrained</pt> | <pt>empty</pt> |
<nt def="nt-richModel">richModel</nt></rhs>
</prod>

</scrap>

<p>A content model constrains the element content of a type specification:
it says nothing about attributes. </p>


<p>Content models do not have names, but appear as a part of the definitions of
types, which do have names.</p>
<p>The <termref def="key-satisfy-cm">satisfy-cm</termref> definition wrt schema-validity obtains.</p>
</div3>

<div3 id="declare-elementOnly">
<head>Rich Content Models</head>
<p>A content model consisting of an <nt def="nt-elementOnly">elemModel</nt>
alone specifies child elements only.  If the <pt>mixed</pt> qualifier is present,
text may occur <emph>as well as</emph> elements. In either case the
content model consists of a simple grammar governing the allowed types of child
elements and the order in which they must appear. </p>

<scrap lang="ebnf" id="RuleSet.XS10">

<head>Rich content model</head>
 <prod id="nt-richModel">
  <lhs>richModel</lhs>
  <rhs xml:space="preserve"><nt def="nt-elementOnly">elemModel</nt> <pt>mixed</pt>?</rhs>
 </prod>
<prod id="nt-elementOnly">
<lhs>elemModel</lhs>
<rhs xml:space="preserve"><nt def="nt-allGroup">allGroup</nt> | <nt def="nt-modelElt">particle</nt></rhs>
</prod>
<prod id="nt-modelElt">
<lhs>particle</lhs>
<rhs xml:space="preserve">( <nt def="nt-element">element</nt> | <nt def="nt-modelGroup">group</nt> | <nt def="nt-wildcard">wildcard</nt> | <nt def="nt-modelGroupRef">modelGroupRef</nt> ) <nt def="nt-occurs">occurs</nt></rhs>
</prod>
<prod id="nt-occurs">
<lhs>occurs</lhs>
<rhs xml:space="preserve"><pt>minOccurs</pt> <pt>maxOccurs</pt></rhs>
</prod>
 <prod id="nt-element">
  <lhs>element</lhs>
  <rhs xml:space="preserve"><nt def="nt-elementRef">elementRef</nt> | <nt def="nt-elementDecl">elementDecl</nt></rhs>
 </prod>
 <prod id="nt-modelGroup">
  <lhs>group</lhs>
  <rhs xml:space="preserve"><nt def="nt-compositor">compositor</nt> <nt def="nt-modelElt">particle</nt> <nt def="nt-modelEltSeq">particleSeq</nt></rhs>
 </prod>
<prod id="nt-compositor">
<lhs>compositor</lhs>
<rhs xml:space="preserve"><pt>sequence</pt> | <pt>choice</pt></rhs>
</prod>
<prod id="nt-modelEltSeq">
<lhs>particleSeq</lhs>
<rhs xml:space="preserve"><nt def="nt-modelElt">particle</nt> <nt def="nt-modelEltSeq">particleSeq</nt>?</rhs>
</prod>
<prod id="nt-allGroup">
  <lhs>allGroup</lhs>
  <rhs xml:space="preserve"><nt def="nt-restrictedElt">restrictedParticle</nt> <nt def="nt-restrictedEltSeq">restrictedParticleSeq</nt></rhs>
 </prod>
 <prod id="nt-restrictedElt">
  <lhs>restrictedParticle</lhs>
  <rhs xml:space="preserve"><nt def="nt-element">element</nt> | <nt def="nt-wildcard">wildcard</nt></rhs>
 </prod>
 <prod id="nt-restrictedEltSeq">
  <lhs>restrictedParticleSeq</lhs>
  <rhs xml:space="preserve"><nt def="nt-restrictedElt">restrictedParticle</nt> <nt def="nt-restrictedEltSeq">restrictedParticleSeq</nt>?</rhs>
 </prod></scrap>

<p><termdef term="particle" id="term-particle">The grammar for element-only content is built on content model <term>particle</term>s (<nt def="nt-modelElt">particle</nt> above)</termdef>: elements,
groups and wildcards.  A particle provides for some
number of occurrences in an instance of a single element (via
<nt def="nt-elementRef">elementRef</nt> or <nt def="nt-elementDecl">elementDecl</nt>), a group of elements (via
<nt def="nt-modelGroup">group</nt>) or an indirect specification of any of
these (via <nt def="nt-modelGroupRef">modelGroupRef</nt>).</p>
 <p><termdef term="permit" id="term-permit">We say that a <termref def="term-particle">particle</termref> <term>permit</term>s one or more elements or groups if its <pt>minOccurs</pt> is 0</termdef>.<termdef term="require" id="term-require">We say that a <termref def="term-particle">particle</termref> <term>require</term>s one or more elements or groups if its <pt>minOccurs</pt> is greater than 0</termdef>.</p>
<p><termdef id="term-group" term="group">A <term>group</term> is two or more particles plus a <nt def="nt-compositor">compositor</nt></termdef>.  The <nt def="nt-compositor">compositor</nt> for a group specifies for a given
group whether it provides for
 <ulist>
  <item><p>a sequence of the elements <termref def="term-permit">permitted</termref> or
<termref def="term-require">required</termref> by its <termref def="term-particle">particles</termref>;</p></item>
  <item><p>a choice between
the elements <termref def="term-permit">permitted</termref> or
<termref def="term-require">required</termref> by its <termref def="term-particle">particles</termref>;</p></item>
  <item><p>a repeated choice among the elements <termref def="term-permit">permitted</termref> or
<termref def="term-require">required</termref> by its <termref def="term-particle">particles</termref>;</p></item>
  <item><p>a set of the elements <termref def="term-require">required</termref> by its <termref def="term-particle">particles</termref> (this is the case for the implicit <code>all</code> compositor,
which is associated with the <nt def="nt-allGroup">allGroup</nt> production).</p></item>
 </ulist>
These options reconstruct the XML
1.0 <code>,</code> connector, the XML 1.0 <code>|</code> connector, the repeated disjunction of XML 1.0's <xtermref href="http://www.w3.org/TR/REC-xml#NT-Mixed">Mixed</xtermref>
production and the SGML
<code>&amp;</code> connector respectively. In the first case (<code>sequence</code>) all the
elements <termref def="term-permit">permitted</termref> or
<termref def="term-require">required</termref> must appear in the order given in the group; in the second case
(<code>choice</code>), exactly one of the <termref def="term-permit">permitted</termref> or
<termref def="term-require">required</termref> elements must appearin the fourth case (<code>all</code>), all the <termref def="term-require">required</termref> elements,
which are restricted in this case only to unqualified
<nt def="nt-element">element</nt>s with <pt>minOccurs</pt>=<pt>maxOccurs</pt>=1, must appear, but may
appear in any order.  The <code>all</code> compositor may
only appear as the top-level compositor of a content model.</p>
<p>The <nt def="nt-occurs">occurs</nt> specification governs how many times the
material <termref def="term-permit">permitted</termref> or
<termref def="term-require">required</termref> by a <nt def="nt-modelElt">particle</nt> may occur, but note that the components of a group whose <nt def="nt-compositor">compositor</nt> is (implicitly) <pt>all</pt> may not be qualified,
and therefore call for exactly one appearance of the element they identify.</p>
<p>See <specref ref="declare-element"/> for further discussion and examples
of the appearance of <nt def="nt-elementDecl">elementDecl</nt> as one of the
two expansions of 
<nt def="nt-element">element</nt> above.</p>
 <p>For the interpretation of
<nt def="nt-wildcard">wildcard</nt> in this context, see
<specref ref="declare-openness"/>.</p>

<!-- Omit example for now - mostly covered in chapter 2.

<note role="example">
<eg xml:space="preserve">&lt;elementTypeRef name="paragraph"/&gt;

&lt;sequence&gt;
 &lt;elementRef name="name1"/&gt;
 &lt;elementRef name="name2" prefix="HTML"/&gt;
&lt;/sequence&gt;

&lt;choice minOccurs="3" maxOccurs="9"&gt;
 &lt;elementRef name="name1"/&gt;
 &lt;elementRef name="name2"/&gt;
&lt;/choice&gt;

&lt;all minOccurs="3"&gt;
 &lt;elementRef name="name1"/&gt;
 &lt;elementRef name="name2"/&gt;
&lt;/all&gt;

&lt;choice&gt;
 &lt;all&gt;
  &lt;elementRef name="name1"/&gt;
  &lt;elementRef name="name2"/&gt;
 &lt;/all&gt;
 &lt;all&gt;
  &lt;elementRef name="name3"/&gt;
  &lt;elementRef name="name4"/&gt;
 &lt;/all&gt;
&lt;/choice&gt;</eg>
<p>A minimal model which simply requires a <code>paragraph</code> (the default
is <code>minOccurs=maxOccurs=1</code>; a sequence of two elements (one from
another schema); between 3 and 9 elements, each a choice between two; at least
three pairs, in any order; one of two pairs, the elements <emph>in</emph> the
chosen pair in any order. </p>
</note>

-->

<p>The <termref def="key-satisfy-eo">satisfy-eo</termref> definition wrt schema-validity obtains.</p>
<p>The <specref ref="cos-elt-consist"/> <termref def="gloss-cos">Constraint on Schemas</termref> obtains.</p>
  <constraintnote type="cos" id="cos-nonambig">
<head>Unambiguous Content Model</head>
<p> For compatibility, it is an error if a content model is such that there
exist element item sequences within which some item can match more than one
occurrence of an <nt def="nt-elementRef">elementRef</nt>, 
<nt def="nt-elementDecl">elementDecl</nt> or <nt def="nt-wildcard">wildcard</nt> in the content model. </p>
</constraintnote>
</div3>
 <div3 id="declare-mixedContent">
<head>Mixed Content</head>
<p>A content model which allows <pt>mixed</pt> content provides for mixing elements with
character data in document instances. The same <nt def="nt-elementOnly">elemModel</nt> mechanism is used for specifying the
grammar of the allowed elements, with the changes that the implicit top-levl
model group has the <code>choice</code> <nt def="nt-compositor">compositor</nt>
and <pt>minOccurs</pt> of 0 and <pt>maxOccurs</pt> of '*', thus ensuring that the default
behaviour is the same as that of XML. </p>


<note role="example">
<eg xml:space="preserve">&lt;type content="mixed"&gt;
 &lt;element ref="name1"/&gt;
 &lt;element ref="name2"/&gt;
 &lt;element ref="name3"/&gt;
&lt;/type&gt;
</eg>
<p>Allows character data mixed with any number of <code>name1</code>,
<code>name2</code> and <code>name3</code> elements.</p>
</note>
<issue id="noEmptyReqd">
 <p>We need to make the <nt def="nt-elementOnly">elemModel</nt> rhs optional, to
allow for <pt>mixed</pt> with no elements specified == our minimum commitment
model.  This in turn would allow us if we chose to get rid of an explicit
<pt>empty</pt> flag:  just specify <code>elementOnly</code> and no model.</p>
 <p>We could then get rid of <pt>any</pt> as well, given other mechanisms for
controlled openness we're contemplating.</p>
 <p>Note that most of this is actually realised in the current version, with
the exception of the observation about <pt>empty</pt>.</p>
</issue>
<p>The <termref def="key-satisfy-mixed">satisfy-mixed</termref> definition wrt schema-validity obtains.</p>
</div3>
<div3 id="declare-namedModelGroup">
<head>Named Model Group</head>
<p>This reconstructs another common use of <termref def="gloss-parameterEntity">parameter entities</termref>.</p>

<scrap lang="ebnf" id="RuleSet.XS12a">

<head>Named model groups</head>
<prod id="nt-modelGroupDefn">
<lhs>modelGroupDefn</lhs>
<rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-modelGroupSpec">modelGroupSpec</nt></rhs>
</prod>
<prod id="nt-modelGroupSpec">
<lhs>modelGroupSpec</lhs>
<rhs xml:space="preserve">( <nt def="nt-allGroup">allGroup</nt> | <nt def="nt-modelGroup">group</nt> | <nt def="nt-element">element</nt> | <nt def="nt-modelGroupRef">modelGroupRef</nt> )</rhs>
</prod>
<prod id="nt-modelGroupRef">
<lhs>modelGroupRef</lhs>
<rhs><nt def="nt-modelGroupName">modelGroupName</nt></rhs>
</prod>
<prod id="nt-modelGroupName">
<lhs>modelGroupName</lhs>
<rhs xml:space="preserve"><pt>QName</pt></rhs>
</prod>

</scrap>
 <p>Groups defined with the <nt def="nt-allGroup">allGroup</nt> option may only
be referenced from a <nt def="nt-modelGroupRef">modelGroupRef</nt> which
constitutes the only <nt def="nt-modelGroup">group</nt> at the top level of a content model.</p>
<note role="example">
<eg xml:space="preserve">&lt;group name="myModelGroup"&gt;
 &lt;element ref="myelement"/&gt;
&lt;/group&gt;

&lt;element name="myelement"&gt;
 &lt;type&gt;
  &lt;group ref="myModelGroup"/&gt;
  &lt;attribute ...&gt;. . .&lt;/attribute&gt;
 &lt;/type&gt;
&lt;/element&gt;

&lt;element name="anotherelement"&gt;
 &lt;type&gt;
  &lt;group order="choice"&gt;
   &lt;element ref="yetAnotherelement"/&gt;
   &lt;group ref="myModelGroup"/&gt;
  &lt;/group&gt;
  &lt;attribute ...&gt;. . .&lt;/attribute&gt;
 &lt;/type&gt;
&lt;/element&gt;
</eg>
<p>A minimal model group is defined and used by reference, first as the whole
content model, then as one alternative in a choice. </p>
</note>
<issue id="named-model-groups">
 <p>In its vote on 1999-11-04, the WG agreed that this section was
still open for discussion.</p>
</issue>
</div3>
<div3 id="declare-element">
<head>Element Declaration</head>
<p>An <termdef id="key-element" term="element declaration"><term>element
declaration</term> associates an element name with a
type</termdef>, either by reference or by incorporation. </p>

<issue id="elt-default">
  <p>The extension of defaulting to element content is tentative. </p>
</issue>
<scrap lang="ebnf" id="RuleSet.XS13">

<head>Element declaration</head>
<prod id="nt-elementDecl">
<lhs>elementDecl</lhs>
<rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-elementSpec">elementSpec</nt></rhs>
</prod>
<prod id="nt-elementSpec">
<lhs>elementSpec</lhs>
<rhs xml:space="preserve">( <nt def="nt-typeRef">typeRef</nt> | <nt def="nt-datatypeRef">datatypeRef</nt> | <nt def="nt-typeSpec">complexTypeSpec</nt> | <nt def="nt-typeSpec">simpleTypeSpec</nt> ) <nt def="nt-valueConstraint">valueConstraint</nt>? <nt def="nt-generalConstraint">generalConstraint</nt>* <nt def="nt-equivClassRef">equivClassRef</nt>? <nt def="nt-final">final</nt> <nt def="nt-exact">exact</nt> <pt>nullable</pt>? <pt>abstract</pt>?</rhs>
</prod>
 <prod id="nt-equivClassRef">
  <lhs>equivClassRef</lhs>
  <rhs><nt def="nt-elementRef">elementRef</nt></rhs>
 </prod>
<prod id="nt-elementRef">
<lhs>elementRef</lhs>
<rhs xml:space="preserve"><nt def="nt-elementName">elementName</nt> </rhs>
</prod>
<prod id="nt-elementName">
<lhs>elementName</lhs>
<rhs xml:space="preserve"><pt>QName</pt> </rhs>
</prod>

</scrap>

<p>An element declaration associates a name with type. This name will appear in tags in instance
documents; the type provides <termref def="SC">SC</termref>s on
the form of elements tagged with the given name. An element 
declaration whose <nt def="nt-elementSpec">elementSpec</nt> is an
<nt def="nt-typeSpec">typeSpec</nt> is comparable to an 
<code>&lt;!ELEMENT ...&gt;</code> declaration in an XML 1.0 DTD.</p>
<p><nt def="nt-elementSpec">elementSpec</nt> not only allows for
element declarations to associate a name with a complex type (by reference or inclusion), but also
allows the reference or specification to be for a simple type, with the
implication that no attributes are allowed in instances and the
text-only content will be constrained appropriately.</p>
<p><nt def="nt-elementRef">elementRef</nt> provides for top-level element declarations to be referenced by
name from content models. </p>
<p>As noted above element names are in a separate
<termref def="key-symbolSpace">symbol space</termref> from the symbol spaces for
the names of types, so there can (but need
not be) a complex type or simple type with the same name as a top-level element.</p> 
<p>The <termref def="key-elt-fullname">elt-fullname</termref> definition wrt schema-validity obtains.</p>
<p>An <nt def="nt-elementDecl">elementDecl</nt> may appear both at the top
level of a schema and within
a <nt def="nt-modelElt">modelElt</nt>. See above (<specref ref="declare-elementOnly"/> and <specref ref="declare-mixedContent"/>) for
where this is allowed. This declares a locally-scoped association between an
element name and a type. As with attribute names, locally-scoped
element names reside in symbol spaces local to the type that defines
them. Note however that type and datatype names are always top-level names within a
schema, even when associated with locally-scoped element names.</p>
 <p>The use above of <nt def="nt-datatypeSpec">simpleTypeSpce</nt> and
<nt def="nt-typeSpec">complexTypeSpec</nt>, which have no provision for names,
is intentional: nested types are anonymous.</p>
 <p>See below at <specref ref="declare-key"/> for <nt def="nt-generalConstraint">generalConstraints</nt>.</p>
<p>An element declared as <pt>nullable</pt> may appear in instances with an
attribute whose name is <code>null</code> from the XML Schema instance namespace and
value <code>true</code> to distinguish a null content from an empty content. 
It is an error for element information items marked
<code>xsi:null="true"</code> to have any content.</p>
 <issue id="nullRequiresEmpty">
  <p>Is it a precondition for being nullable that the element's contentType
allow no content?  If not, then more needs to be said above, if so, this needs
to be spelled out.</p>
 </issue>

<note role="example">
<eg xml:space="preserve">&lt;element name="myelement" type="mySimpleType"/&gt;

&lt;element name="et0" type="myComplexType"/&gt;

&lt;element name="et1"&gt;
 &lt;type&gt;
  &lt;element ref="et0"/>
  . . .
  &lt;attribute ...&gt;. . .&lt;/attribute&gt;
 &lt;/type&gt;
&lt;/element&gt;

&lt;element name="et2"&gt;
 &lt;type content="empty"&gt;
  &lt;attribute ...&gt;. . .&lt;/attribute&gt;
 &lt;/type&gt;
&lt;/element&gt;
</eg>
<p>The first two examples above declare elements by reference to a simple and a
complex type respectively.  The third and fourth use embedded anonymous complex
types, the first of which in
turn refers to one of the top-level elements in its content model.</p>
<eg xml:space="preserve">&lt;element name="contextOne"&gt;
 &lt;type&gt;
  &lt;element name="myLocalelement" type="myFirstType"/&gt;
  &lt;element ref="globalelement"/&gt;
 &lt;/type&gt;
&lt;/element&gt;

&lt;element name="contextTwo"&gt;
 &lt;type&gt;
  &lt;element name="myLocalelement" type="mySecondType"/&gt;
  &lt;element ref="globalelement"/&gt;
 &lt;/type&gt;
&lt;/element&gt;
</eg>
<p>Instances of <code>myLocalelement</code> within
<code>contextOne</code> will be constrained by <code>myFirstType</code>,
while those within <code>contextTwo</code> will be constrained by
<code>mySecondType</code>. </p>

</note>
<note>
<p>The possibility that differing attribute declarations and/or content models
would apply to elements with the same name in different contexts is an
extension beyond the expressive power of a DTD in XML 1.0.</p>
</note>
<p>In the concrete syntax above, the <code>type</code> attribute is used to
encode both the <termref def="nt-typeRef">typeRef</termref> or <termref def="nt-datatypeRef">datatypeRef</termref> options.  In the case where there are both a
simple type and a complex type of the referenced name in the relevant schema, the
ambiguity is resolved in favour of the complex type.</p>
 <note>
  <p>See <loc href="#note-two-sses">previous note on the ambiguity issue</loc>.</p>
 </note>
<ednote><edtext> existing section on element declaration should be updated to
cover instance syntax.</edtext></ednote>
<p>The <specref ref="cos-local-global"/> <termref def="gloss-cos">Constraint on Schemas</termref> obtains.</p>
<p>The <termref def="key-satisfy-ed">satisfy-ed</termref> definition wrt schema-validity obtains.</p>
<p>The <termref def="key-ind-valid">ind-valid</termref> definition wrt schema-validity obtains.</p>
<p>The <termref def="key-satisfy-etr">satisfy-etr</termref> definition wrt schema-validity obtains.</p>
</div3>
</div2>
   <div2 id="declare-openness">
    <head>Wildcards</head>
   <p>In order to exploit the full potential for extensibility offered by XML
plus namespaces, more provision is needed than DTDs allow for targeted flexibility in content
models and attribute declarations.  At a given point in a content model, in
addition to what DTDs provide for we need <termref def="term-particle">particles</termref> that allow the following:</p>
   <olist>
    <item>
     <p>Any well-formed XML element item: any tag, any namespace, any attributes,
any content, as long as it's well-formed;</p>
    </item>
    <item>
     <p>Any well-formed XML element item, provided it's in some <emph>other</emph>
namespace than the one we're defining a type for;</p>
    </item>
    <item>
     <p>Any well-formed XML element item, provided it's in a specified namespace;</p>
    </item>
    <item>
     <p>Any well-formed XML element item, provided it's from the <emph>same</emph>
namespace as the one we're defining a type for.</p>
    </item>
   </olist>
   <p>Of course, by qualifying one of these with a <B>*</B>, we allow for any
amount of (localized) flexibility in validation.</p>
   <p>Attributes need the same kind of flexibility:  a good-citizen schema
should probably allow any attributes from the <code>xml:</code> namespace, for instance.</p>
    <scrap lang="ebnf" id="Ruleset.XS20">
     <head>Wildcards</head>
     <prod id="nt-wildcard">
      <lhs>wildcard</lhs>
      <rhs xml:space="preserve"><pt>any</pt> | <pt>otherNS</pt> |
<nt def="nt-allowedNS">allowedNSList</nt> | <pt>sameNS</pt></rhs>
     </prod>
     <prod id="nt-allowedNS">
      <lhs>allowedNSList</lhs>
      <rhs xml:space="preserve"><pt>myNS</pt>? <pt>URI</pt>*</rhs>
     </prod>
     <prod id="nt-anyAttr">
      <lhs>attrWildcard</lhs>
      <rhs xml:space="preserve"><nt def="nt-wildcard">wildcard</nt></rhs>
     </prod>
    </scrap>
    <p>The four alternatives for <nt def="nt-wildcard">wildcard</nt>
correspond to the four kinds of flexibility listed above.</p>
    <p>All of the above are subject to the same ambiguity constraints
(<specref ref="cos-nonambig"/>) as other
content model particles:  If an instance element could match either an explicit
particle and a wildcard, or one of two wildcards, within the content model of a
type, that model is in error.</p>
   
    <note role="example"><eg xml:space="preserve"><![CDATA[<any/>

<any namespace="##other"/>

<any namespace="http://www.w3.org/1999/Style/Transform/">

<any namespace="##targetNamespace"/>

<anyAttribute namespace="http://www.w3.org/XML/1998/namespace"/>]]></eg>
    <p>Concrete examples of the four cases listed above, plus one attribute case.</p>
</note>
   </div2>
<div2 id="declare-refinement">
<head>Deriving Type Definitions</head>
<p>This section articulates what has only been hinted at above, namely a
considerable increase in the power and expressiveness of schema declarations,
by explaining what was provided for in the abstract syntax in the previous
section, but not explained much if at all at that point:  the potential for
deriving new type definitions on the basis of old ones.  <termdef id="derived" term="derived">We call such a new definition a <term>derived</term> type definition</termdef>, and <termdef id="source" term="source">the old definition it is derived from the <term>source</term> type definition</termdef>.</p>
<p>We provide two means for deriving type definitions from other type definitions, each of which implies a partial order over the types defined in a
schema:  A
type definition may either <emph>restrict</emph> or <emph>extend</emph> another
type definition.</p>
 <div3 id="declare-embed">
  <head>Deriving type definitions by extension</head>
  <p>A new type complex type can be defined by adding additional content model
particles at the end of the element-only content model of another complex definition
and/or by adding attribute declarations to any type definition.  Members of
a type whose definition is derived in this way, i.e. by extension, will
always contain members of their source type within them
as prefixes.</p>
  <scrap>
   <head>Extension</head>
  <prod id="nt-typeSpec2" role="prefig">
    <lhs>complexTypeSpec</lhs>
    <rhs xml:space="preserve"><nt def="nt-contentType">contentType</nt> <nt def="nt-attrsSpec">attributesSpec</nt>? <nt def="nt-final">final</nt> <nt def="nt-exact">exact</nt> <pt>abstract</pt>?</rhs> 
  </prod>
<prod id="nt-contentType">
<lhs>contentType</lhs>
<rhs xml:space="preserve"><nt def="nt-embedding">extension</nt> | <nt def="nt-restriction">restriction</nt></rhs>
</prod>
 <prod id="nt-embedding">
 <lhs>extension</lhs>
  <rhs xml:space="preserve"><nt def="nt-datatypeRef">simpleTypeRef</nt> | ( <nt def="nt-typeRef">complexTypeRef</nt> <nt def="nt-contentModel">contentModel</nt> )</rhs>
</prod>
  </scrap>
<p>For the time being, the effective content model of a type definition
derived by extension from another complex type is
composed by appending its <nt def="nt-contentModel">contentModel</nt> to that of the source
definition.  It follows from this that the source definition must be complex
and element-only if the <nt def="nt-contentModel">contentModel</nt> is not
empty.  If it <emph>is</emph> empty, there is no constraint on the nature of the
source definition, which may be simple or complex (thus the <nt def="nt-datatypeRef">simpleTypeRef</nt> above).  In either case, attributes may be added.</p>
  <note>
   
   <p>The restriction to appending in the case of content-model extension
simplifies application processing in order to cast instances from derived to
source type.  We may liberalise this in future versions, requiring more
complex transformations to effect casting.</p>
  </note>
  <note role="example">
   <eg xml:space="preserve"><![CDATA[<type name="personName">
 <element name="title" minOccurs="0"/>
 <element name="forename" minOccurs="0" maxOccurs="*"/>
 <element name="surname"/>
</type>

<type name="extendedName" source="personName" derivedBy="extension">
 <element name="generation" minOccurs="0"/>
</type>

<element name="addressee" type="extendedName"/>

  <addressee>
   <forename>Albert</forename>
   <forename>Arnold</forename>
   <surname>Gore</surname>
   <generation>Jr</generation>
  </addressee>]]></eg>
   <p>A type definition for personal names, and a definition derived by
extension which adds a single element; an element declaration referencing the
derived definition, and a valid instance thereof.</p>
  </note>
 </div3>
<div3 id="declare-supertype">
  <head>Deriving type definitions by restriction</head>
  <p>A new type can be defined by decreasing the possibilities made available by an
existing type definition:  narrowing ranges, removing alternatives, etc.
Restriction is specified bottom up, via <nt def="nt-datatypeRestr">simpleRestrictions</nt> or <nt def="nt-typeRestr">complexRestrictions</nt> in a <nt def="nt-typeSpec">complexTypeSpec</nt>, in either case referring to its <termref def="source">source</termref> definition with a <nt def="nt-typeRef">complexTypeRef</nt>.  Members of a type whose definition is derived in this way, i.e. by restriction, will always be members of their source type as well.</p>
<scrap id="Ruleset.XS23">
 <head>Restriction</head>
 <prod id="nt-restriction">
 <lhs>restriction</lhs>
  <rhs xml:space="preserve">( <nt def="nt-typeRef">complexTypeRef</nt> <nt def="nt-typeRestr">complexRestrictions</nt> ) |  ( <nt def="nt-typeRef">complexTypeRef</nt> <nt def="nt-datatypeRestr">simpleRestrictions</nt> ) | <nt def="nt-contentModel">contentModel</nt></rhs>
</prod>
 <prod id="nt-datatypeRestr">
  <lhs>simpleRestrictions</lhs>
  <rhs xml:space="preserve"><nt def="nt-facet">facet</nt>+</rhs>
 </prod> 
 <prod id="nt-typeRestr">
  <lhs>complexRestrictions</lhs>
  <rhs xml:space="preserve">( <nt def="nt-modelElt">particle</nt> |
<pt>sic</pt> )* <nt def="nt-attrsSpec">attributesSpec</nt></rhs>
 </prod>
</scrap>
  <p>A definition by restriction will restrict some of the permissions or obligations inherited
therefrom.  This means that
if the <termref def="source">source</termref> definition has text-only content,
the <nt def="nt-datatypeRestr">simpleRestrictions</nt> option must be used, and its facets must each narrow the
corresponding facet of the <termref def="source">source</termref> definition, e.g. by reducing a range or removing
members of an enumeration.</p>
  <p>If the <termref def="source">source</termref> definition has element-only
or mixed content, restricting a content model is also possible via the <nt def="nt-typeRestr">complexRestrictions</nt> option.  In this case each <termref def="term-particle">particle</termref> within the restriction is matched one for one with the corresponding particle in the <termref def="source">source</termref> definition, and in each case a restriction must be effected, e.g. by narrowing the range of <nt def="nt-occurs">occurs</nt>, by reducing the members of a disjunction or by replacing a <nt def="nt-wildcard">wildcard</nt> with a more explicit <termref def="nt-modelElt">particle</termref>.</p>
  <p>In either case, attributes
may be restricted by adding and/or fixing defaults, or by restricting the
attribute's simple type definition.</p>
 <p>The bare <nt def="nt-contentModel">contentModel</nt> option reflects the
fact that type definitions without a source type, consisting simply of a
content model, are interpreted as restricting the ur-type.</p>
  <note role="example">
   <eg xml:space="preserve"><![CDATA[<type name="simpleName" source="personName" derivedBy="restriction">
 <restrictions>
  <element name="title" maxOccurs="0"/>
  <element name="forename" minOccurs="1" maxOccurs="1"/>
 </restrictions>
</type>

<element name="who" type="simpleName"/>

   <who>
    <forename>Bill</forename>
    <surname>Clinton</surname>
   </who>]]></eg>
   <p>A simplified type definition
derived from the source type from the previous example by restriction, eliminating one optional daughter and
fixing another to occur exactly once; an element declared by reference to it,
and a valid instance thereof.</p>
  </note>
 </div3>
 <div3 id="final_and_abstract">
  <head>Controlling derivation</head>
  <p>A type definition can control the extent to which other types may be
derived from it, the ways it may appear in content models and the
import of those appearances.</p>
  <scrap>
   <head>Derivation control</head>
  <prod id="nt-typeSpec3" role="prefig">
    <lhs>complexTypeSpec</lhs>
    <rhs xml:space="preserve"><nt def="nt-contentType">contentType</nt> <nt def="nt-attrsSpec">attributesSpec</nt>? <nt def="nt-final">final</nt>
<nt def="nt-exact">exact</nt> <pt>abstract</pt>?</rhs> 
  </prod>
<prod id="nt-final">
<lhs>final</lhs>
<rhs xml:space="preserve"><pt>extension</pt>? <pt>restriction</pt>?</rhs>
</prod>
<prod id="nt-exact">
<lhs>exact</lhs>
<rhs xml:space="preserve"><pt>extension</pt>? <pt>restriction</pt>? <pt>equivClass</pt>?</rhs>
</prod>
  </scrap>
<p>An <pt>abstract</pt> type definition may not be referenced from a <nt def="nt-modelElt">particle</nt>, nor may it be used in an instance
as the value of <code>xsi:type</code> (see below).</p>
<p>A type definition may prevent its use as a source for derived
definitions by any or all means by declaring itself <nt def="nt-final">final</nt> for the prohibited means.  In the absence of <nt def="nt-final">final</nt> the value of <nt def="nt-finalDefault">finalDefault</nt> from the containing schema is used.</p>
<p>A type definition may declare that it is <nt def="nt-exact">exact</nt>:  although not <pt>abstract</pt>,
none-the-less types derived by any or all means from it may not appear
in its place even when an <nt def="nt-element">element</nt> <nt def="nt-modelElt">particle</nt>
naming it would appear to allow this (see below).  In the absence of <nt def="nt-exact">exact</nt> the value of <nt def="nt-exactDefault">exactDefault</nt> from the containing schema is used.</p>
 </div3>
   <div3 id="invariant-GI">
    <head>Reinterpreting Content Models</head>
    <p>In the light of type derivation, we propose to elaborate the
significance of <nt def="nt-element">element</nt> when it serves as a <nt def="nt-modelElt">particle</nt>.  An <nt def="nt-element">element</nt> which specifies a type (either locally or by reference) which is the <termref def="source">source</termref> of other types is understood as allowing that type or any of the types derived from it to govern its occurance in instances.</p>
    <p>This introduces an ambiguity if the
source type is not <code>abstract</code> and/or has a derived type which is
substitutable for another derived type.  This is resolved by requiring instance
elements allowed via in this way which conform to types other than
the source type to
manifest their type using the <code>type</code> attribute from the XML Schema
instance namespace,
e.g. <code>xsi:type</code>.</p>
<p>If either the <nt def="nt-element">element</nt> <nt def="nt-modelElt">particle</nt> or the referenced type definition is <nt def="nt-exact">exact</nt> for some or all kind of derivation, then this
elaboration doesn't happen for those derivations, i.e. types derived in those
ways may <emph>not</emph> appear.</p>
    <p>This facility is intended to provide
a good impedence match with the needs of database and object-oriented
programming applications.</p>
    <note role="example">
     <eg xml:space="preserve"><![CDATA[<type name="WorldAddress"
      source="po:Address" derivedBy="extension">
 <element name="country" type="string"/>
</type>

<type name="GermanAddress"
      source="po:WorldAddress" derivedBy="extension">
 <element name="land" type="string/>
</type>

<element name="person">
 <type>
  . . .
  <element name="address" type="po:Address"/>
 </type>
</element>

  <person>
   ...
   <address>
    ...
   </address>
  </person>

  <person>
   <address xsi:type="GermanAddress">
    ...
    <country>Germany</country>
    <land>Saarland</land>
   </address>
  </person>]]></eg>
     <p>Two types derived from the <code>Address</code> type defined in <specref ref="sampleSchema"/> are defined, adding first a <code>country</code> and then a <code>land</code> element to its required content.  Two schema-valid instances of an element declared with type <code>Address</code> are shown, one using that type itself, and therefore not requiring disambiguation, and one using the <code>xsi:type</code> attribute to indicate that it is using the <code>GermanAddress</code> type.</p>
    </note>
   </div3>
 <div3 id="declare-equiv">
  <head>Element Equivalence Classes</head>
  <p>We provide a mechanism to allow bottom-up specification of disjunctions
over elements in content models.  An element declared at the top level can
declare itself to be a member of an equivalence class by reference to the
exemplar of that class, itself an element declared at the top level.</p>
  <scrap>
   <head>Element Equivalence Classes</head>
<prod id="nt-elementDecl3" role="prefig">
<lhs>elementDecl</lhs>
<rhs xml:space="preserve"><pt>NCName</pt> <nt def="nt-elementSpec">elementSpec</nt></rhs>
</prod>
   <prod id="nt-elementSpec3" role="prefig">
<lhs>elementSpec</lhs>
<rhs xml:space="preserve">( <nt def="nt-typeRef">typeRef</nt> | <nt def="nt-datatypeRef">datatypeRef</nt> | <nt def="nt-typeSpec">complexTypeSpec</nt> | <nt def="nt-typeSpec">simpleTypeSpec</nt> ) <nt def="nt-valueConstraint">valueConstraint</nt>? <nt def="nt-generalConstraint">generalConstraint</nt>* <nt def="nt-equivClassRef">equivClassRef</nt>? <nt def="nt-final">final</nt> <nt def="nt-exact">exact</nt> <pt>nullable</pt>? <pt>abstract</pt>?</rhs>
</prod>
 <prod id="nt-equivClassRef2" role="prefig">
  <lhs>equivClassRef</lhs>
  <rhs><nt def="nt-elementRef">elementRef</nt></rhs>
 </prod>
<prod id="nt-final3" role="prefig">
<lhs>final</lhs>
<rhs xml:space="preserve"><pt>extension</pt>? <pt>restriction</pt>?</rhs>
</prod>
<prod id="nt-exact3" role="prefig">
<lhs>exact</lhs>
<rhs xml:space="preserve"><pt>extension</pt>? <pt>restriction</pt>? <pt>equivClass</pt>?</rhs>
</prod>
 <prod id="nt-element3" role="prefig">
  <lhs>element</lhs>
  <rhs xml:space="preserve"><nt def="nt-elementRef">elementRef</nt> | <nt def="nt-elementDecl">elementDecl</nt></rhs>
 </prod>
  </scrap>
  <p>The type of every member of an equivalence class must be the same as or derived from the
type of the exemplar.</p>
  <p>In a way similar to the reinterpretation of the <nt def="nt-element">element</nt> <nt def="nt-modelElt">particle</nt> discussed in the previous section, we further extend the significance thereof by saying that an <nt def="nt-element">element</nt> <nt def="nt-modelElt">particle</nt> of the <nt def="nt-elementRef">elementRef</nt> form which references the exemplar of an equivalence class is understood as allowing not only the referenced element but any member of its equivalence class in instances.</p>
  <p>Vacuous type derivation is allowed, i.e. an equivalence class member may
have the <emph>same</emph> type as the exemplar of its class.  The concrete
syntax makes this easy by allowing element declarations which specify an <nt def="nt-equivClassRef">equivClassRef</nt> to specify no type at all, in which case they are taken to have the same type as their exemplar.</p>
  <p>If an <nt def="nt-element">element</nt> is <pt>abstract</pt>, then
although references to it can appear in content models, it cannot itself allow
element information items with its name to appear in instances:  only instances
of elements declared with it as their exemplar, if any, may appear.</p>
  <p>If an <nt def="nt-element">element</nt> is <nt def="nt-exact">exact</nt> for some or all kinds of derivation, then this
elaboration doesn't happen for those derivations, i.e. elements other than the
exemplar may <emph>not</emph> appear if their type is derived from that of the
exemplar in a proscribed way.  The <code>equivClass</code> value for <nt def="nt-exact">exact</nt> prevents equivalence class member substitution without preventing derived type substitution per <specref ref="invariant-GI"/>.</p>
  <p>If an <nt def="nt-element">element</nt> is <nt def="nt-final">final</nt>
for some or all kinds of derivation, elements whose type is derived from their
source by the proscribed means may not nominate this element as the exemplar of
their <nt def="nt-equivClassRef">equivClassRef</nt>.</p>
  <note role="example">
   <eg xml:space="preserve"><![CDATA[  <type name="facet" source="annotated" derivedBy="extension">
    <attribute name="value" minOccurs="1"/>
  </type>

  <element name="facet" type="facet" abstract="true"/>

  <element name="encoding" equivClass="facet">
   <type source="facet" derivedBy="restriction">
    <attribute name="value" type="encodings"/>
   </type>
  </element>

  <element name="period" equivClass="facet">
   <type source="facet" derivedBy="restriction">
    <attribute name="value" type="timeDuration"/>
   </type>
  </element>

  <type name="datatype">
    <element ref="facet" minOccurs="0" maxOccurs="*"/>
    <attribute name="name" type="NCName" minOccurs="0">
    . . .
  </type>
]]></eg>
   <p>An example from the schema for datatypes from &XSP2;.  The
<code>facet</code> type is defined
and the <code>facet</code> element is declared to use it. The <code>facet</code> element is abstract -- it's
<emph>only</emph> defined to stand as the exemplar for a class).  Two further
elements are declared, each a member of the <code>facet</code> equivalence
class.  Finally a type is defined which refers to <code>facet</code>, thereby
allowing <emph>either</emph> <code>period</code> or <code>encoding</code> (or
any other member of the class).</p>
  </note>
 </div3>
 <div3 id="declare-ur">
  <head>The ur-type</head>
  <p><termdef id="term-ur-type" term="ur-type">Any schema implicitly defines an <term>ur-type</term>, which is
the source for all types, simple or complex, which do not identify an
explicit source type</termdef>, and the default type for elements and
attributes which do not specify one.  You can think of the <termref def="term-ur-type">ur-type</termref> as if it were defined as follows
for complex types:</p>
  <eg xml:space="preserve"><![CDATA[<type name="ur-type" content="mixed">
 <any/>
 <anyAttribute/>
</type>]]></eg>
  <p>The <code>mixed</code> content specification together with the
unconstrained wildcard content model and attribute specification produce the defining property for the
ur-type, namely that <emph>every</emph> type is a restriction of it:  its permissions and requirements are
the least restrictive possible.</p>
<p>There is no way to notate the <termref def="term-ur-type">ur-type</termref> from the perspective of simple
types:  it's defining property is simply that all the ab-initio types
are derived from it by restriction.</p>
 </div3>
<div3>
 <head>Graveyard for stale syntax, here to avoid breaking IDREFs
elsewhere *</head>
<p><termdef id="key-refine" term="refine">a type AT1 is said to
<term>refine</term> a type AT2 if and only if AT1 is declared to refine
either AT2 or (recursively) some type that refines AT2</termdef>.
<termdef id="key-ancestor" term="ancestor">AT2 is then said to be an
<term>ancestor</term> of AT1. </termdef>
<termdef id="key-effective" term="effective">The <term>effective</term>
constraints are the union of the explicit and the acquired</termdef>.</p></div3>
</div2>
   <div2 id="declare-key">
    <head>Unique, key and key reference constraints</head>
    <p>We supplement the simple uniqueness and reference mechanisms provided by
<code>ID</code> and <code>IDREF</code> in XML 1.0 and SGML with three new kinds
of constraint, for uniqueness, keys and key references.</p>
    <p>The <nt def="nt-unique">unique</nt> and <nt def="nt-key">key</nt> constraints provide for selected
elements to be checked as having locally or globally unique identities.  The
<nt def="nt-keyref">keyref</nt> constraint provides for checking referential consistency with
respect to a declared <nt def="nt-unique">unique</nt> or <nt def="nt-key">key</nt> constraint.</p>
    <p>These constraints are specified independently of the types of the
attributes and elements involved, i.e. something declared as of type integer
may also serve as a key, unlike <code>ID</code> and
<code>IDREF</code>.  Each constraint declaration has a name, which exists in a
single symbol space for constraints.</p>
    <p>Overall the augmentations to XML's <code>ID/IDREF</code> mechanism are:</p>
    <ulist>
     <item><p>Not just attribute values, but also element content and combinations
of values and content can be declared to be unique;</p></item>
     <item><p>Constraints can be specified to have document-wide scope
<emph>or</emph> to hold within the scope of particular elements;</p></item>
     <item><p>(Combinations of) attribute values and/or element content can be
declared to be keys, that is, not only unique, but always present and non-nullable.</p></item>
    </ulist>
    <scrap id="Ruleset.XS24">
<head>Uniqueness Constraints</head>
     <prod id="nt-generalConstraint">
      <lhs>generalConstraint</lhs>
      <rhs xml:space="preserve"><nt def="nt-constraintName">constraintName</nt>
( <nt def="nt-unique">unique</nt> | <nt def="nt-key">key</nt> | <nt def="nt-keyref">keyref</nt> )</rhs>
     </prod>
     <prod id="nt-unique">
      <lhs>unique</lhs>
      <rhs xml:space="preserve"> <nt def="nt-selector">selector</nt> <nt def="nt-field">field</nt>+</rhs>
     </prod>
     <prod id="nt-key">
      <lhs>key</lhs>
      <rhs xml:space="preserve"> <nt def="nt-selector">selector</nt> <nt def="nt-field">field</nt>+</rhs>
     </prod>
     <prod id="nt-keyref">
      <lhs>keyref</lhs>
      <rhs xml:space="preserve"> <nt def="nt-selector">selector</nt> <nt def="nt-field">field</nt>+ <nt def="nt-refer">refer</nt></rhs>
     </prod>
     <prod id="nt-constraintName">
      <lhs>constraintName</lhs>
      <rhs><pt>NCName</pt></rhs>
     </prod>
     <prod id="nt-refer">
      <lhs>refer</lhs>
      <rhs><pt>QName</pt></rhs>
     </prod>
     <prod id="nt-selector">
      <lhs>selector</lhs>
      <rhs><pt>XPath_Expr</pt></rhs>
     </prod>
     <prod id="nt-field">
      <lhs>field</lhs>
      <rhs><pt>XPath_Expr</pt></rhs>
     </prod>
    </scrap>
    <p><nt def="nt-selector">selector</nt> specifies an XPath expression <bibref ref="bib-xpath"/> relative to
instances of the element being declared, or to the root for <nt def="nt-generalConstraint">generalConstraints</nt> declared at the top level. This must identify a node set of subelements (i.e. elements contained within the declared element) to which the constraint applies.</p>
    <p><nt def="nt-field">field</nt> specifies an XPath expression relative to each
element selected by a <nt def="nt-selector">selector</nt>.  This must identify
a single node (element or attribute, not necessarily within the selected element) whose content or value, which must be
of a simple type, is used in the constraint.  It is possible to specify an
ordered list of <nt def="nt-field">field</nt>s, to cater to multi-field keys,
keyrefs, and uniqueness constraints.  A <nt def="nt-field">field</nt> must not
evaluate to the same element or attribute as any other <nt def="nt-field">field</nt> in a given instance of a <nt def="nt-generalConstraint">generalConstraint</nt>.
     <note>
      <p>Provision for multi-field keys etc. goes beyond what is supported by <code>xsl:key</code>.</p>
     </note></p>
    <issue id="restrictConstrXPaths">
<p>
Xpaths can take arbitrarily complicated forms and it is unnecessary to burden
XML Schema implementations with supporting every feature of XPath.  The XPaths
in <nt def="nt-selector">selector</nt> and <nt def="nt-field">field</nt> should be restricted to certain specified simple forms.</p>
    </issue>
    <issue id="fieldOnlyKeyref">
     <p>Should the selector be made optional in a keyref, with default the
element it's contained within?</p>
    </issue>
    <issue id="islandValidConstraint">
     <p>What are the implications of constraints if we support island
validation constraints?</p>
    </issue>
    <p>The <nt def="nt-refer">refer</nt> of a <nt def="nt-keyref">keyref</nt>
must match the <nt def="nt-constraintName">constraintName</nt> of a <nt def="nt-unique">unique</nt> or a <nt def="nt-key">key</nt>.  The number of <nt def="nt-field">fields</nt> of the <nt def="nt-keyref">keyref</nt> must be the same as the number of <nt def="nt-field">fields</nt> of the referenced <nt def="nt-unique">unique</nt> or <nt def="nt-key">key</nt>.  For every element which is identified in a given scope by the <nt def="nt-selector">selector</nt> of a <nt def="nt-keyref">keyref</nt> defined for that scope (call this <B>ref</B>), there must be an element in that scope identified by the <nt def="nt-selector">selector</nt> of the named <nt def="nt-unique">unique</nt> or <nt def="nt-key">key</nt> (call this <B>target</B>) such that the values of the <nt def="nt-field">fields</nt> of the <nt def="nt-keyref">keyref</nt> evaluated with respect to <B>ref</B>, taken in order, match the values of the <nt def="nt-field">fields</nt> of the <nt def="nt-unique">unique</nt> or <nt def="nt-key">key</nt> evaluated with respect to <B>target</B>.</p>
    <note>
     <p>If reference to a key or unique defined in a scoping element which may
occur more than once is envisaged, then the scoping elements themselves must
have keys (typically with global scope), and the scoped keys must include the
key of their scoping element among their fields.</p>
    </note>
    <note role="example">
     <eg xml:space="preserve"><![CDATA[<element name="state"> 
  <type> 
   <element name="stateCode" type="twoLetterCode"/>

    <element name="vehicle"> 
      <type> 
       . . .
       <attribute name="regNo" type="integer"/>
      </type> 
    </element> 

    . . .
  </type> 

</element> 

<key name="regKey"> 
  <selector>.//vehicle[@regNo]</selector>
  <field>@regNo</field>
  <field>ancestor::state/stateCode</field>
      <!-- scope needs to be involved -->
</key> 

<element name="person"> 
 <type> 
 . . .
  <element name="car">
   <type model="empty">
    . . .
    <attribute name="regRef" type="integer"/>
    <attribute name="regState" type="twoLetterCode"/>
   </type> 
  </element> 
 </type>

 <keyref name="carRef" refer="regKey">
  <selector>.//car[@regRef]</selector> 
   <field>@regRef</field>
   <field>../person/@regState</field>
 </keyref> 
</element>]]></eg>
     <p>A <code>state</code> element is defined, which <emph>inter alia</emph>
contains a <code>stateCode</code> descendant and some <code>vehicle</code>
descendants.  A <code>vehicle</code> in turn has a <code>regNo</code> attribute,
which is an integer.  The combination of <code>stateCode</code> and
<code>regNo</code> is asserted to be a <nt def="nt-key">key</nt> for
<code>vehicle</code> within <code>state</code>.  Furthermore, a <code>person</code> element has
inter-alia an empty <code>car</code> element, with <code>regRef</code> and
<code>regState</code> attributes, which are then asserted together to refer to
<code>vehicles</code> via the <code>regKey</code> constraint.</p>
    </note>
   </div2>
<div2 id="declare-entity">
<head>Notations</head>

<scrap lang="ebnf" id="RuleSet.XS15">

<head>Notations</head>
<prod id="nt-notationDecl">
<lhs>notationDecl</lhs>
<rhs><pt>NCName</pt> <nt def="nt-notationSpec">notationSpec</nt></rhs>
</prod>
<prod id="nt-notationSpec">
<lhs>notationSpec</lhs>
<rhs><nt def="nt-systemID">systemID</nt> <nt def="nt-notationRef">notationRef</nt> <nt def="nt-publicID">publicID</nt>?</rhs>
</prod>
<prod id="nt-systemID">
<lhs>systemID</lhs>
<rhs><pt>URI</pt></rhs>
</prod>
<prod id="nt-publicID">
<lhs>publicID</lhs>
<rhs>
<com>see <bibref ref="ref-xml"/></com></rhs>
</prod>
<prod id="nt-notationRef">
<lhs>notationRef</lhs>
<rhs><nt def="nt-notationName">notationName</nt></rhs>
</prod>
<prod id="nt-notationName">
<lhs>notationName</lhs>
<rhs><pt>QName</pt></rhs>
</prod>

</scrap>
<div3 id="declare-notation">
<head>Notation Declaration</head>
<p>A notation may be declared by specifying a name and an identifier for the
notation.</p>
<note>
<eg xml:space="preserve">
&lt;notation name="jpeg"
          public="image/jpeg" system="viewer.exe" /&gt;

&lt;element name="picture"&gt;
 &lt;type source="binary" derivedBy="extension"&gt;
  &lt;attribute name="pictype" type="NOTATION"/&gt;
 &lt;/type&gt;
&lt;/element&gt;

&lt;picture pictype="jpeg"&gt;...&lt;/picture>
</eg>
<p>The notation need not ever be mentioned in the instance document.</p>

</note>
</div3>
</div2>
</div1>
   <div1 id="composition">
    <head>Schema Access and Composition</head>
<p>This chapter defines the mechanisms by which we establish the necessary precondition for establishing schema-validity, namely access to one or more schemas. This chapter also describes in detail related mechanisms for using in
one schema, definitions and declarations from another. </p>
<p>Chapter 6 provides a formal definition of schema-validation. Here we describe
a 3-layer architecture which incorporates that formal definition and relates it
to XML documents and WWW-situated processes. This layering is provided to
maximize the range of environments in which this specification can be applied,
and to minimize the need for modifications to this specification as new
standards and conventions for Web interoperability are developed. The layers
are: </p>
<olist>
  <item><p>The schema-validation core; </p></item>
  <item><p>Schema definition: the connections between the XML Schema concrete syntax
  defined in the preceding chapter and the validation core, including the
  relationships between namespaces and schema components; </p></item>
  <item><p>XML Schema web-interoperability guidelines: instance-&gt;schema and
  schema-&gt;schema connections for the WWW. </p></item></olist>
<p>Layer 1 specifies the manner in which a set of schema components can be applied to validate an instance element. Layer 2, which is
primarily defined in Chapter 3, specifies the use of <code>&lt;schema&gt;</code>
elements in XML documents as the standard XML representation for
schema information in a broad range of computer systems and execution
environments. To support interoperation over the World Wide Web in particular,
layer 3 provides a set of conventions for schema reference on the
Web. </p>
<p>We note that improved or alternative conventions for Web interoperability can
be standardized in the future without reopening this recommendation. For
example, the W3C is currently considering initiatives to standardize the
packaging of resources relating to particular documents and/or namespaces: this
would be an addition to the mechanisms described here for layer 3. This
architecture also facilitates innovation at layer 2: for example, it would be
possible in the future to define an additional standard for the representation of
schema components which allowed e.g. type definitions to be specified piece by
piece, rather than all at once.</p>

<div2 id="layer1">
<head>Layer 1: Summary of the schema-validation core </head>
<ednote><edtext> Some of this text will probably end up in Chapter 6</edtext></ednote>
<p>The fundamental purpose of the schema-validation core is to define schema-validatity for a single
element information item and its descendants with respect to a specified type
definition. All processors are req