view src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/xmlschema-for-jaxb.rng @ 285:f50545b5e2f1

7150322: Stop using drop source bundles in jaxws Reviewed-by: darcy, ohrstrom
author ohair
date Tue, 06 Mar 2012 16:09:35 -0800
parents
children 7b66429f8b48
line wrap: on
line source
<?xml version="1.0"?>
<!--
 Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

 This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.  Oracle designates this
 particular file as subject to the "Classpath" exception as provided
 by Oracle in the LICENSE file that accompanied this code.

 This code is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 version 2 for more details (a copy is included in the LICENSE file that
 accompanied this code).

 You should have received a copy of the GNU General Public License version
 2 along with this work; if not, write to the Free Software Foundation,
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 or visit www.oracle.com if you need additional information or have any
 questions.
-->

<grammar xmlns="http://relaxng.org/ns/structure/1.0"
      datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
      ns="http://www.w3.org/2001/XMLSchema"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:doc="http://www.jenitennison.com/doc"
      xmlns:txw="http://java.sun.com/txw">

<doc:p>
  RELAX NG schema for XML Schema by <doc:link 
  href="mailto:mail@jenitennison.com">Jeni Tennison</doc:link>. Based on 
  <doc:link href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/">XML 
  Schema Part I: Structures Recommendation</doc:link> and <doc:link 
  href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/">XML Schema Part 
  II: Datatypes</doc:link>.
</doc:p>
<doc:changes date="2001-11-24">
  <doc:p>
    Amended to comply with 10 August 2001 Tutorial.
  </doc:p>
  <doc:change>Removed key attributes.</doc:change>
  <doc:change>Replaced not element with except elements.</doc:change>
  <doc:change>
    Replaced multiple consecutive optional attributes to use the 
    zeroOrMore/choice pattern.
  </doc:change>
  <doc:change>
    Removed interleave elements inside list elements (which are no longer 
    permitted).
  </doc:change>
</doc:changes>

<define name="openAttrs" txw:mode="inherit">
  <doc:p>
    This allows any number of attributes that are not in the XML Schema 
    namespace or are in no namespace.  This is somewhat more complicated than 
    the XML Schema anyAttribute equivalent. 
  </doc:p>
  <!-- KK don't care -->
  <empty/>
  <!--zeroOrMore>
    <attribute>
      <anyName>
        <except>
          <nsName />
          <nsName ns="" />
          <name>xml:lang</name>
        </except>
      </anyName>
      <text />
    </attribute>
  </zeroOrMore-->
</define>

<define name="annotated" txw:mode="inherit">
  <doc:p>
    This allows any number of attributes that are not in the XML Schema 
    namespace or are in no namespace, an optional id attribute of type ID, 
    and an optional annotation element.  This is used as the basis for many 
    element content models.
  </doc:p>
  <ref name="openAttrs" />
  <optional>
    <attribute name="id">
      <data type="ID" />
    </attribute>
  </optional>
  <optional>
    <ref name="annotation" />
  </optional>
</define>

<define name="schemaTop" txw:mode="inline">
  <doc:p>
    This gives the content model of the top level of the schema.
  </doc:p>
  <choice>
    <ref name="redefinable" />
    <ref name="topLevelElement" />
    <ref name="topLevelAttribute" />
    <!--ref name="notation" /-->
  </choice>
</define>

<define name="redefinable" txw:mode="inline">
  <doc:p>
    This gives the components that can be redefined within the redefine 
    element.  They also occur at the top level of the schema.
  </doc:p>
  <choice>
    <ref name="simpleTypeHost" />
    <ref name="complexTypeHost" />
    <!--ref name="namedGroup" />
    <ref name="namedAttributeGroup" /-->
  </choice>
</define>

<define name="formChoice">
  <doc:p>
    This gives the values for the various form attributes: 
    elementFormDefault and attributeFormDefault on the schema element, and
    the form attributes on the element and attribute elements.
  </doc:p>
  <choice>
    <value>qualified</value>
    <value>unqualified</value>
  </choice>
</define>

<!-- KK: merge the two -->
<define name="reducedDerivationControl">
  <doc:p>
    This gives the values that can be taken in the lists used to control
    derivation by extension or restriction (this is 'reduced' derivation
    because some derivation can involve substitution).  This RELAX NG schema, 
    like the XML Schema Recommendation here, allows the keywords 'extension' and 
    'restriction' to be repeated any number of times.
  </doc:p>
  <list>
    <oneOrMore>
      <choice>
        <value>extension</value>
        <value>restriction</value>
      </choice>
    </oneOrMore>
  </list>
</define>

<define name="derivationSet">
  <doc:p>
    This specifies the possible values for attributes that control derivation.
  </doc:p>
  <choice>
    <value>#all</value>
    <ref name="reducedDerivationControl" />
  </choice>
</define>

<start>
  <doc:p>
    This is the beginning point for the schema, and defines the schema 
    element.
  </doc:p>
  <element name="schema" 
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-schema">
    <ref name="openAttrs" />
    <zeroOrMore>
      <choice>
        <attribute name="version">
          <data type="token" />
        </attribute>
        <attribute name="finalDefault">
          <ref name="derivationSet" />
        </attribute>
        <attribute name="blockDefault">
          <ref name="blockSet" />
        </attribute>
        <attribute name="attributeFormDefault">
          <ref name="formChoice" />
        </attribute>
        <attribute name="elementFormDefault">
          <ref name="formChoice" />
        </attribute>
        <attribute name="id">
          <data type="ID" />
        </attribute>
        <attribute name="xml:lang">
          <data type="language" />
        </attribute>
        <attribute name="targetNamespace">
          <data type="anyURI" />
        </attribute>
      </choice>
    </zeroOrMore>
    <zeroOrMore>
      <choice>
        <!--ref name="include" /-->
        <ref name="import" />
        <!--ref name="redefine" /-->
        <ref name="annotation" />
      </choice>
    </zeroOrMore>
    <zeroOrMore>
      <choice>
        <ref name="schemaTop" />
        <ref name="annotation" />
      </choice>
    </zeroOrMore>
  </element>
</start>

<define name="allNNI">
  <doc:p>
    This gives the value type for the maxOccurs attribute, which may be a 
    non-negative number or the keyword 'unbounded'.
  </doc:p>
  <choice>
    <data type="nonNegativeInteger" />
    <value type="token">unbounded</value>
  </choice>
</define>

<define name="occurs" txw:mode="inherit">
  <doc:p>
    This specifies the occurs attributes, minOccurs and maxOccurs, as they 
    are normally used.
  </doc:p>
  <zeroOrMore>
    <choice>
      <attribute name="minOccurs">
        <data type="nonNegativeInteger" />
      </attribute>
      <attribute name="maxOccurs">
        <ref name="allNNI" />
      </attribute>
    </choice>
  </zeroOrMore>
</define>

<define name="typeDefParticle" txw:mode="inline">
  <doc:p>
    This gives the possible content of complex types.
  </doc:p>
  <choice>
    <!--ref name="groupRef" /-->
    <ref name="all" />
    <ref name="choice" />
    <ref name="sequence" />
  </choice>
</define>

<define name="nestedParticle" txw:mode="inline">
  <doc:p>
    This gives the particles that can make up a model group.
  </doc:p>
  <choice>
    <ref name="localElement" />
    <!--ref name="groupRef" /-->
    <ref name="choice" />
    <ref name="sequence" />
    <ref name="any" />
  </choice>
</define>

<define name="fixedOrDefault" txw:mode="inline">
  <doc:p>
    This specifies the relationship between fixed and default attributes on 
    element and attribute elements - if one is present, then the other cannot 
    be.  This is a constraint that cannot be specified using XML Schema.
  </doc:p>
  <choice>
    <empty />
    <attribute name="fixed" />
    <attribute name="default" />
  </choice>
</define>

<define name="attributeType" txw:mode="inherit">
  <doc:p>
    This specifies the relationship between the type attribute and the 
    simpleType element child of attribute elements - if one is present, then 
    the other cannot be, although it is possible for neither to be allowed.
  </doc:p>
  <choice>
    <empty />
    <attribute name="type">
      <data type="QName" />
    </attribute>
    <ref name="simpleTypeHost" />
  </choice>
</define>

<define name="localAttribute">
  <doc:p>
    This describes attribute elements when used in a local context.  They 
    have an optional use attribute, possibly a fixed or default attribute, 
    and then can either have a ref attribute (referring to a top-level 
    attribute) or a name attribute with an optional form attribute and 
    specifying an attribute type.
  </doc:p>
  <element name="attribute" 
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-attribute">
    <ref name="annotated" />
    <optional>
      <attribute name="use">
        <choice>
          <value type="token">optional</value>
          <value type="token">prohibited</value>
          <value type="token">required</value>
        </choice>
      </attribute>
    </optional>
    <ref name="fixedOrDefault" />
    <choice>
      <attribute name="ref">
        <data type="QName" />
      </attribute>
      <group>
        <attribute name="name">
          <data type="NCName" />
        </attribute>
        <optional>
          <attribute name="form">
            <ref name="formChoice" />
          </attribute>
        </optional>        
        <ref name="attributeType" />
      </group>
    </choice>
  </element>
</define>

<define name="topLevelAttribute">
  <doc:p>
    This describes attribute elements when used at the top level of the 
    schema.  They must have a name, may have a fixed or default attribute, 
    and specify their type through a type attribute or child simpleType 
    element.  The name attribute of each attribute element that appears at 
    the top level of the schema is unique.
  </doc:p>
  <element name="attribute"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-attribute">
    <ref name="annotated" />
    <attribute name="name">
      <data type="NCName" />
    </attribute>
    <ref name="fixedOrDefault" />
    <ref name="attributeType" />
  </element>
</define>

<define name="attrDecls" txw:mode="inherit">
  <doc:p>
    This gives the model group for specifying the attributes in a complex 
    type, an extension or restriction.
  </doc:p>
  <zeroOrMore>
    <choice>
      <ref name="localAttribute" />
      <!--ref name="attributeGroupRef" /-->
    </choice>
  </zeroOrMore>
  <optional>
    <ref name="anyAttribute" />
  </optional>
</define>

<define name="anyAttribute">
  <doc:p>
    This specifies the anyAttribute wildcard.
  </doc:p>
  <element name="anyAttribute"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-anyAttribute">
    <ref name="wildcard" />
  </element>
</define>

<define name="complexTypeModel" txw:mode="inherit">
  <doc:p>
    This specifies the content of a complexType element.  As children, it can 
    have a simpleContent, a complexContent or a model group.  Only if it has 
    one of the latter two, may it have a mixed attribute.  This latter 
    constraint is something that cannot be specified in XML Schema.
  </doc:p>
  <choice>
    <ref name="simpleContent" />
    <group>
      <optional>
        <attribute name="mixed">
          <data type="boolean" />
        </attribute>
      </optional>
      <choice>
        <ref name="complexContent" />
        <group>
          <optional>
            <ref name="typeDefParticle" />
          </optional>
          <ref name="attrDecls" />
        </group>
      </choice>
    </group>
  </choice>
</define>

<define name="complexTypeHost" txw:mode="inherit">
  <ref name="typeHost" />
  <ref name="complexType" />
</define>

<define name="typeHost" txw:mode="inherit"><empty/><empty/></define>

<define name="complexType" txw:mode="inherit">
  <element name="complexType"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-complexType">
    <doc:p>
      This specifies the basic content of a complexType element.
    </doc:p>
    <ref name="annotated" />
    <ref name="complexTypeModel" />
    <optional>
      <attribute name="name">
        <data type="NCName" />
      </attribute>
    </optional>
    <zeroOrMore>
      <choice>
        <attribute name="abstract">
          <data type="boolean" />
        </attribute>
        <attribute name="block">
          <ref name="derivationSet" />
        </attribute>
        <attribute name="final">
          <ref name="derivationSet" />
        </attribute>
      </choice>
    </zeroOrMore>
  </element>
</define>

<define name="complexRestriction">
  <doc:p>
    This describes a restriction element within a complexContent element 
    (i.e. one that restricts a complex type).  It has a base attribute, may 
    contain a model group and may contain attribute declarations of various 
    sorts.
  </doc:p>
  <element name="restriction"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-complexContent::restriction">
    <ref name="annotated" />
    <attribute name="base">
      <data type="QName" />
    </attribute>
    <optional>
      <ref name="typeDefParticle" />
    </optional>
    <ref name="attrDecls" />
  </element>
</define>

<define name="extensionType">
  <doc:p>
    This specifies the basic model for an extension element: adding a 
    required base attribute to the model used for most components.
  </doc:p>
  <ref name="annotated" />
  <attribute name="base">
    <data type="QName" />
  </attribute>
</define>

<define name="complexExtension">
  <doc:p>
    This describes an extension element within a complexContent element 
    (i.e. one that restricts a complex type).  It may contain a model group 
    and may contain attribute declarations of various sorts.
  </doc:p>
  <element name="extension"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-complexContent::extension">
    <ref name="extensionType" />
    <optional>
      <ref name="typeDefParticle" />
    </optional>
    <ref name="attrDecls" />
  </element>
</define>

<define name="complexContent">
  <doc:p>
    This describes a complexContent element.  It may have a mixed attribute, 
    and either a restriction or extension element as content.
  </doc:p>
  <element name="complexContent"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-complexContent">
    <ref name="annotated" />
    <optional>
      <attribute name="mixed">
        <data type="boolean" />
      </attribute>
    </optional>
    <choice>
      <ref name="complexRestriction" />
      <ref name="complexExtension" />
    </choice>
  </element>
</define>

<define name="simpleRestriction">
  <doc:p>
    This describes a restriction element that appears within a simpleContent 
    or simpleType element (i.e. one that restricts a simple type).  Its 
    content follows the simple restriction model that is detailed below, and 
    may include attribute declarations.
  </doc:p>
  <element name="restriction"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-simpleContent::restriction">
    <ref name="annotated" />
    <ref name="simpleRestrictionModel" />
    <ref name="attrDecls" />
  </element>
</define>

<define name="simpleExtension">
  <doc:p>
    This describes an extension element that appears within a simpleContent 
    element (i.e. one that extends a simple type).  Like other extensions, it 
    has a base type, but it can only be used to add attributes.
  </doc:p>
  <element name="extension"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-simpleContent::extension">
    <ref name="extensionType" />
    <ref name="attrDecls" />
  </element>
</define>

<define name="simpleContent">
  <doc:p>
    This describes a simpleContent element, whose content can either hold a 
    restriction or extension element.
  </doc:p>
  <element name="simpleContent"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-simpleContent">
    <ref name="annotated" />
    <choice>
      <ref name="simpleRestriction" />
      <ref name="simpleExtension" />
    </choice>
  </element>
</define>

<define name="blockSet">
  <doc:p>
    This gives the possible values for block attributes on element elements, 
    which includes substitution amongst the list of possible values.  This 
    RELAX NG schema, like the XML Schema Recommendation, allows each of the 
    keywords 'extension', 'restriction' and 'substitution' to occur more than 
    once within the list.
  </doc:p>
  <choice>
    <value type="token">#all</value>
    <list>
      <oneOrMore>
        <choice>
          <value>extension</value>
          <value>restriction</value>
          <value>substitution</value>
        </choice>
      </oneOrMore>
    </list>
  </choice>
</define>

<define name="element" txw:mode="inherit">
  <doc:p>
    This describes the basic content model of an element element.  It is 
    annotated, may have a fixed or default attribute, and may have nillable 
    and/or block attributes.  Its type may be specified through a type 
    attribute, a local simple type or a local complex type - the choice 
    between these methods is something that cannot be indicated with XML 
    Schema.  This content is optionally followed by some identify constraints.
  </doc:p>
  <ref name="annotated" />
  <ref name="fixedOrDefault" />
  <zeroOrMore>
    <choice>
      <attribute name="nillable">
        <data type="boolean" />
      </attribute>
      <attribute name="block">
        <ref name="blockSet" />
      </attribute>
    </choice>
  </zeroOrMore>
  <choice>
    <empty />
    <attribute name="type">
      <data type="QName" />
    </attribute>
    <ref name="simpleTypeHost" />
    <ref name="complexTypeHost" />
  </choice>
  <!--zeroOrMore>
    <ref name="identityConstraint" />
  </zeroOrMore-->
</define>

<define name="topLevelElement">
  <doc:p>
    This describes an element element that appears at the top level of the 
    schema.  On top of the basic content for an element element, it has to 
    have a name, which is a unique identifier in the element symbol space.  It 
    may have substitutionGroup, abstract and/or final attributes.
  </doc:p>
  <element name="element"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-element">
    <ref name="element" />
    <attribute name="name">
      <data type="NCName" />
    </attribute>
    <zeroOrMore>
      <choice>
        <attribute name="substitutionGroup">
          <data type="QName" />
        </attribute>
        <attribute name="abstract">
          <data type="boolean" />
        </attribute>
        <attribute name="final">
          <ref name="derivationSet" />
        </attribute>
      </choice>
    </zeroOrMore>
  </element>
</define>

<define name="localElement">
  <doc:p>
    This describes an element element that appears locally, within a 
    complexType or group element.  It may have minOccurs and/or maxOccurs 
    attributes.  If it has a ref attribute, then that&apos;s all it can 
    have.  Otherwise, it must have a name and specifies its type in the same 
    way as the basic element content model described above.  It may in this 
    case also have a form element.  These constraints on local elements 
    cannot be described within XML Schema.
  </doc:p>
  <element name="element"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-element">
    <ref name="occurs" />
    <choice>
      <attribute name="ref">
        <data type="QName" />
      </attribute>
      <group>
        <ref name="element" />
        <attribute name="name">
          <data type="NCName" />
        </attribute>
        <optional>
          <attribute name="form">
            <ref name="formChoice" />
          </attribute>
        </optional>
      </group>
    </choice>
  </element>
</define>

<!--define name="namedGroup">
  <doc:p>
    This describes an group element that appears at the top level of the 
    schema.  It must have a name attribute, and must have one of an all, 
    choice or sequence element child.
  </doc:p>
  <element name="group"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-group">
    <ref name="annotated" />
    <attribute name="name">
      <data type="NCName" />
    </attribute>
    <choice>
      <element name="all">
        <ref name="simpleExplicitGroup" />  <!- - RS - relaxed all content model - ->
      </element>
      <element name="choice">
        <ref name="simpleExplicitGroup" />
      </element>
      <element name="sequence">
        <ref name="simpleExplicitGroup" />
      </element>
    </choice>
  </element>
</define-->

<!--define name="groupRef">
  <doc:p>
    This describes group element that occurs locally, referring to a 
    top-level named group.  It may have occurrence attributes, and must have 
    a ref attribute.
  </doc:p>
  <element name="group"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-group">
    <ref name="annotated" />
    <ref name="occurs" />
    <attribute name="ref">
      <data type="QName" />
    </attribute>
  </element>
</define-->

<define name="explicitGroup" txw:mode="inherit">
  <doc:p>
    This gives the content of a model group (not a group element) in the 
    normal run of things.  It has occurrence attributes and any number of 
    particles within it.
  </doc:p>
  <ref name="annotated" />
  <ref name="occurs" />
  <zeroOrMore>
    <ref name="nestedParticle" />
  </zeroOrMore>
</define>

<define name="simpleExplicitGroup">
  <doc:p>
    This gives the content of a model group (not a group element) within a 
    named group - it differs from the above in that it doesn&apos;t have any 
    occurrence attributes.
  </doc:p>
  <ref name="annotated" />
  <zeroOrMore>
    <ref name="nestedParticle" />
  </zeroOrMore>
</define>

<define name="all">
  <doc:p>
    This describes an all element that appears outside a named group (i.e. as 
    the content of a complexType element).  It has the standard model for an 
    all element, but adds minOccurs and maxOccurs attributes which can only 
    take certain values.
  </doc:p>
  <element name="all"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-all">
    <ref name="explicitGroup" />
  </element>
</define>

<define name="choice">
  <doc:p>
    This describes a choice element that appears outside a named group.
  </doc:p>
  <element name="choice"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-choice">
    <ref name="explicitGroup" />
  </element>
</define>

<define name="sequence">
  <doc:p>
    This describes a sequence element that appears outside a named group.
  </doc:p>
  <element name="sequence"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-sequence">
    <ref name="explicitGroup" />
  </element>
</define>

<define name="wildcard" txw:mode="inherit">
  <doc:p>
    This describes a wildcard element (i.e. any or anyAttribute).  The 
    namespace attribute can take a list URIs interspersed with the keywords 
    '##targetNamespace' and/or '##local'.  This RELAX NG schema, like the XML 
    Schema Recommendation, allows the keywords to be specified more than once 
    each within the list, if they&apos;re given.  This model also specifies the 
    processContents attribute.
  </doc:p>
  <ref name="annotated" />
  <zeroOrMore>
    <choice>
      <attribute name="namespace">
        <choice>
          <value type="token">##any</value>
          <value type="token">##other</value>
          <list>
            <zeroOrMore>
              <choice>
                <data type="anyURI" />
                <value>##targetNamespace</value>
                <value>##local</value>
              </choice>
            </zeroOrMore>
          </list>
        </choice>
      </attribute>
      <attribute name="processContents">
        <choice>
          <value type="token">lax</value>
          <value type="token">skip</value>
          <value type="token">strict</value>
        </choice>
      </attribute>
    </choice>
  </zeroOrMore>
</define>

<define name="any">
  <doc:p>
    This describes an any element as a wildcard.
  </doc:p>
  <element name="any"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-any">
    <ref name="wildcard" />
    <ref name="occurs" />
  </element>
</define>

<!--define name="namedAttributeGroup">
  <doc:p>
    This describes an attributeGroup element as it appears at the top level 
    of the schema.  It must have a name attribute, and then contains 
    attribute declarations.
  </doc:p>
  <element name="attributeGroup"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-attributeGroup">
    <ref name="annotated" />
    <attribute name="name">
      <data type="NCName" />
    </attribute>
    <ref name="attrDecls" />
  </element>
</define-->

<!--define name="attributeGroupRef">
  <doc:p>
    This describes an attributeGroup element as it appears within a complex 
    type.  It must have a ref attribute.
  </doc:p>
  <element name="attributeGroup"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-attributeGroup">
    <ref name="annotated" />
    <attribute name="ref">
      <data type="QName" />
    </attribute>
  </element>
</define-->

<!--define name="include">
  <doc:p>
    This describes an include element, which must have a schemaLocation 
    attribute.
  </doc:p>
  <element name="include"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-include">
    <ref name="annotated" />
    <attribute name="schemaLocation">
      <data type="anyURI" />
    </attribute>
  </element>
</define-->

<!--define name="redefine">
  <doc:p>
    This describes a redefine element, which must have a schemaLocation 
    attribute and can then contain any mix of annotations and redefinable 
    components.
  </doc:p>
  <element name="redefine"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-redefine">
    <ref name="openAttrs" />
    <optional>
      <attribute name="id">
        <data type="ID" />
      </attribute>
    </optional>
    <attribute name="schemaLocation">
      <data type="anyURI" />
    </attribute>
    <zeroOrMore>
      <choice>
        <ref name="annotation" />
        <ref name="redefinable" />
      </choice>
    </zeroOrMore>
  </element>
</define-->

<define name="import">
  <doc:p>
    This describes an import element that&apos;s used when its parent schema 
    element specifies a targetNamespace.  In these cases, the namespace 
    attribute on the import element is optional.
  </doc:p>
  <element name="import"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-import">
	  <ref name="annotated" />
	  <optional>
	    <attribute name="schemaLocation">
	      <data type="anyURI" />
	    </attribute>
	  </optional>
    <optional>
      <attribute name="namespace">
        <data type="anyURI" />
      </attribute>
    </optional>
  </element>
</define>

<!--define name="selector">
  <doc:p>
    This describes a selector element.  The xpath attribute is a simplified 
    XPath - the regular expression given here is the one from the XML Schema 
    for XML Schema.
  </doc:p>
  <element name="selector"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-selector">
    <ref name="annotated" />
    <attribute name="xpath">
      <data type="token">
        <param name="pattern">(\.//)?(((child::)?((\i\c*:)?(\i\c*|\*)))|\.)(/(((child::)?((\i\c*:)?(\i\c*|\*)))|\.))*(\|(\.//)?(((child::)?((\i\c*:)?(\i\c*|\*)))|\.)(/(((child::)?((\i\c*:)?(\i\c*|\*)))|\.))*)*</param>
      </data>
    </attribute>
  </element>
</define>

<define name="field">
  <doc:p>
    This describes a field element.  The xpath attribute is a simplified 
    XPath - the regular expression given here is the one from the XML Schema 
    for XML Schema.
  </doc:p>
  <element name="field"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-field">
    <ref name="annotated" />
    <attribute name="xpath">
      <data type="token">
        <param name="pattern">(\.//)?((((child::)?((\i\c*:)?(\i\c*|\*)))|\.)/)*((((child::)?((\i\c*:)?(\i\c*|\*)))|\.)|((attribute::|@)((\i\c*:)?(\i\c*|\*))))(\|(\.//)?((((child::)?((\i\c*:)?(\i\c*|\*)))|\.)/)*((((child::)?((\i\c*:)?(\i\c*|\*)))|\.)|((attribute::|@)((\i\c*:)?(\i\c*|\*)))))*</param>
      </data>
    </attribute>
  </element>
</define>

<define name="keybase" txw:mode="inherit">
  <doc:p>
    This gives the basic content for identity constraints - a name attribute 
    that uniquely identifies the identity constraint, a selector element and 
    one or more field elements.
  </doc:p>
  <ref name="annotated" />
  <attribute name="name">
    <data type="NCName" />
  </attribute>
  <ref name="selector" />
  <oneOrMore>
    <ref name="field" />
  </oneOrMore>
</define>

<define name="identityConstraint" txw:mode="inline">
  <doc:p>
    This gives a model group for the three identity constraint elements, used 
    within the content of element elements.
  </doc:p>
  <choice>
    <ref name="unique" />
    <ref name="key" />
    <ref name="keyref" />
  </choice>
</define>

<define name="unique">
  <doc:p>
    This describes a unique element.
  </doc:p>
  <element name="unique"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-unique">
    <ref name="keybase" />
  </element>  
</define>

<define name="key">
  <doc:p>
    This describes a key element.
  </doc:p>
  <element name="key"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-key">
    <ref name="keybase" />
  </element>
</define>

<define name="keyref">
  <doc:p>
    This describes a keyref element.
  </doc:p>
  <element name="keyref"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-keyref">
    <ref name="keybase" />
    <attribute name="refer">
      <data type="QName" />
    </attribute>
  </element>
</define-->

<!--define name="notation">
  <doc:p>
    This describes a notation element.  The names of notation elements are 
    unique in the notation symbol space.  The public attribute is required, 
    and the system attribute is optional.
  </doc:p>
  <element name="notation"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-notation">
    <ref name="annotated" />
    <attribute name="name">
      <data type="NCName" />
    </attribute>
    <attribute name="public">
      <data type="token" />
    </attribute>
    <optional>
      <attribute name="system">
        <data type="anyURI" />
      </attribute>
    </optional>
  </element>
</define-->

<define name="appinfoContent">
  <doc:p>
    This is designed to describe the content of the appinfo elements in the 
    schema.  At the moment this allows any mixed content without validation.  
    Note that this is fairly complex compared to the XML Schema equivalent, 
    which would be a single any element.
  </doc:p>
  <ref name="anyContent" />
</define>

<define name="anyContent">
  <empty/>  <!-- KK don't care -->
  <!--mixed>
    <zeroOrMore>
      <element>
        <anyName />
        <zeroOrMore>
          <attribute>
            <anyName />
          </attribute>
        </zeroOrMore>
        <ref name="anyContent" />
        <empty />
      </element>
    </zeroOrMore>
  </mixed-->
</define>

<define name="appinfo">
  <doc:p>
    This describes an appinfo element.  It has an optional source attribute 
    and can currently contain anything at all.
  </doc:p>
  <element name="appinfo"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-appinfo">
    <optional>
      <attribute name="source">
        <data type="anyURI" />
      </attribute>
    </optional>
    <ref name="appinfoContent" />
  </element>
</define>

<define name="documentationContent">
  <doc:p>
    This is designed to describe the content of the documentation elements in 
    the schema.  At the moment this allows any mixed content without 
    validation.  Note that this is fairly complex compared to the XML Schema 
    equivalent, which would be a single any element.
  </doc:p>
  <ref name="anyContent" />
</define>

<define name="documentation">
  <doc:p>
    This describes a documentation element.  It has optional source 
    and xml:lang attributes and can currently contain anything at all.
  </doc:p>
  <element name="documentation"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-documentation">
    <zeroOrMore>
      <choice>
        <attribute name="source">
          <data type="anyURI" />
        </attribute>
        <attribute name="xml:lang">
          <data type="language" />
        </attribute>
      </choice>
    </zeroOrMore>
    <ref name="documentationContent" />
  </element>
</define>

<define name="annotation">
  <doc:p>
    This describes an annotation element.  It can have any attributes, may 
    have an id attribute, and contains any number of documentation or appinfo 
    elements.
  </doc:p>
  <element name="annotation"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-annotation">
    <ref name="openAttrs" />
    <optional>
      <attribute name="id">
        <data type="ID" />
      </attribute>
    </optional>
    <zeroOrMore>
      <choice>
        <ref name="documentation" />
        <ref name="appinfo" />
      </choice>
    </zeroOrMore>
  </element>
</define>

<define name="simpleDerivation" txw:mode="inline">
  <doc:p>
    This gives the various types of derivation of simple types.
  </doc:p>
  <choice>
    <ref name="simpleRestriction" />
    <ref name="list" />
    <ref name="union" />
  </choice>
</define>

<define name="simpleDerivationSet">
  <doc:p>
    This specifies the values of the final attribute for simple types.  This 
    RELAX NG schema for XML Schema, like the XML Schema Recommendation, allows 
    the keywords 'list', 'union' and 'restriction' to appear more than once 
    within the list.
  </doc:p>
  <choice>
    <value type="token">#all</value>
    <list>
      <zeroOrMore>
        <choice>
          <value>list</value>
          <value>union</value>
          <value>restriction</value>
        </choice>
      </zeroOrMore>
    </list>
  </choice>
</define>

<define name="simpleTypeHost" txw:mode="inherit">
  <ref name="typeHost" />
  <ref name="simpleType" />
</define>

<define name="simpleType" txw:mode="inherit">
  <doc:p>
    This gives the basic content of a simple type.
  </doc:p>
  <element name="simpleType"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-simpleType">
    <ref name="annotated" />
    <ref name="simpleDerivation" />
    <optional>
      <attribute name="name">
        <data type="NCName" />
      </attribute>
    </optional>
    <optional>
      <attribute name="final">
        <ref name="simpleDerivationSet" />
      </attribute>
    </optional>
  </element>
</define>

<!--define name="rangeFacets" txw:mode="inherit">
  <doc:p>
    This describes the relationship between the various range facets.  Only 
    one of minExclusive and minInclusive can be present, and only one of 
    maxExclusive and maxInclusive can be present.  This is a constraint that 
    can&apos;t easily be expressed using XML Schema.  This RELAX NG schema 
    for XML Schema is a little more restrictive than the XML Schema 
    Recommendation in that it also forces there to be a maximum of one of 
    each of these types of facets.
  </doc:p>
  <interleave>
    <optional>
      <choice>
        <ref name="minExclusive" />
        <ref name="minInclusive" />
      </choice>
    </optional>    
    <optional>
      <choice>
        <ref name="maxExclusive" />
        <ref name="maxInclusive" />
      </choice>
    </optional>
  </interleave>
</define>

<define name="digitFacets" txw:mode="inherit">
  <doc:p>
    This specifies optional totalDigits and fractionDigits elements.  This 
    RELAX NG schema for XML Schema is a little more restrictive than the XML 
    Schema Recommendation in that it also forces there to be a maximum of one 
    of each of these types of facets.
  </doc:p>
  <optional>
    <ref name="totalDigits" />
  </optional>
  <optional>
    <ref name="fractionDigits" />
  </optional>
</define>

<define name="lengthFacets" txw:mode="inherit">
  <doc:p>
    This specifies optional length, minLength and maxLength elements.  This 
    RELAX NG schema for XML Schema is a little more restrictive than the XML 
    Schema Recommendation in that it also forces there to be a maximum of one 
    of each of these types of facets, and says that if a length element is 
    given, then neither minLength nor maxLength should be present.
  </doc:p>
  <choice>
    <ref name="length" />
    <interleave>
      <optional>
        <ref name="minLength" />
      </optional>
      <optional>
        <ref name="maxLength" />        
      </optional>
    </interleave>
  </choice>
</define>

<define name="commonFacets" txw:mode="inherit">
  <doc:p>
    This specifies zero or more enumeration or pattern elements and an 
    optional whiteSpace element.  This RELAX NG schema for XML Schema is a 
    little more restrictive than the XML Schema Recommendation in that it 
    also forces there to be a maximum of one whiteSpace element within the 
    facets.  Note that the whiteSpace facet is constrained to have a value of 
    'collapse'.
  </doc:p>
  <zeroOrMore>
    <ref name="enumeration" />
  </zeroOrMore>
  <optional>
    <ref name="whiteSpaceCollapse" />
  </optional>
  <zeroOrMore>
    <ref name="pattern" />
  </zeroOrMore>
</define-->

<define name="simpleRestrictionModel">
  <doc:p>
    This specifies the types of facets that are valid in restrictions on the 
    built-in data types.  This can only perform rudimentary checking, but 
    should be enough in most circumstances.  Note that for xs:anySimpleType 
    and xs:string, the whiteSpace facet can take any value, for 
    xs:normalizedString it can be 'replace' or 'collapse', and for all other 
    built-in types it has to be 'collapse'.
  </doc:p>
  <choice>
    <attribute name="base">
      <data type="QName" />
    </attribute>
    <ref name="simpleTypeHost" />
  </choice>
  <interleave>
    <!--ref name="rangeFacets" />
    <ref name="digitFacets" />
    <ref name="lengthFacets" />
    <optional>
      <ref name="whiteSpace" />
    </optional-->
    <zeroOrMore>
      <ref name="enumeration" />
    </zeroOrMore>
    <!--zeroOrMore>
      <ref name="pattern" />
    </zeroOrMore-->
  </interleave>
</define>

<define name="list">
  <doc:p>
    This describes a list element.  It can either specify a local simple type 
    or have a itemType attribute.  This constraint cannot be expressed in XML 
    Schema.
  </doc:p>
  <element name="list"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-list">
    <ref name="annotated" />
    <choice>      
      <ref name="simpleTypeHost" />
      <attribute name="itemType">
        <data type="QName" />
      </attribute>
    </choice>
  </element>
</define>

<define name="union">
  <doc:p>
    This describes a union element.  If the memberTypes attribute is missing 
    or empty, then it must contain one or more simpleType elements; if 
    it&apos;s present, then it can contain simpleType elements or list simple 
    types in the memberTypes attribute.  This constraint cannot be expressed 
    in XML Schema.
  </doc:p>
  <element name="union"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-union">
    <ref name="annotated" />
    <choice>
      <group>
        <attribute name="memberTypes">
          <list>
            <oneOrMore>
              <data type="QName" />
            </oneOrMore>
          </list>
        </attribute>
        <zeroOrMore>
          <ref name="simpleTypeHost" />
        </zeroOrMore>
      </group>
      <group>
        <optional>
          <attribute name="memberTypes">
            <empty />
          </attribute>
        </optional>
        <oneOrMore>
          <ref name="simpleTypeHost" />
        </oneOrMore>
      </group>
    </choice>
  </element>
</define>

<define name="facet" txw:mode="inherit">
  <doc:p>
    This is the basic content of a facet.  It has an optional fixed attribute.
  </doc:p>
  <ref name="annotated" />
  <optional>
    <attribute name="fixed">
      <data type="boolean" />
    </attribute>
  </optional>
</define>

<define name="noFixedFacet" txw:mode="inherit">
  <doc:p>
    This is the content of a facet that cannot be fixed (enumeration or 
    pattern).  It has a value attribute that can take any kind of value.
  </doc:p>
  <ref name="annotated" />
  <attribute name="value" />
</define>

<!--define name="rangeFacet">
  <doc:p>
    This is the content of a range facet.  The value must be one of the data 
    types shown (as these are the only types of data that accept ranges).  I 
    haven&apos;t gone so far as to indicate the data type of the value 
    attribute of a range facet according to the base type as this would be 
    very complicated (although it would be possible in RELAX NG).
  </doc:p>
  <ref name="facet" />
  <attribute name="value">
    <choice>
      <data type="decimal" />
      <data type="float" />
      <data type="double" />
      <data type="duration" />
      <data type="dateTime" />
      <data type="time" />
      <data type="date" />
      <data type="gYearMonth" />
      <data type="gYear" />
      <data type="gMonthDay" />
      <data type="gMonth" />
      <data type="gDay" />
    </choice>
  </attribute>
</define>

<define name="minExclusive">
  <doc:p>
    This describes a minExclusive element.
  </doc:p>
  <element name="minExclusive"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-minExclusive">
    <ref name="rangeFacet" />
  </element>
</define>

<define name="minInclusive">
  <doc:p>
    This describes a minInclusive element.
  </doc:p>
  <element name="minInclusive"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-minInclusive">
    <ref name="rangeFacet" />
  </element>
</define>

<define name="maxExclusive">
  <doc:p>
    This describes a maxExclusive element.
  </doc:p>
  <element name="maxExclusive"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-maxExclusive">
    <ref name="rangeFacet" />
  </element>
</define>

<define name="maxInclusive">
  <doc:p>
    This describes a maxInclusive element.
  </doc:p>
  <element name="maxInclusive"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-maxInclusive">
    <ref name="rangeFacet" />
  </element>
</define>

<define name="numFacet">
  <doc:p>
    This is the content of a numerical facet.
  </doc:p>
  <ref name="facet" />
  <attribute name="value">
    <data type="nonNegativeInteger" />
  </attribute>
</define>

<define name="totalDigits">
  <doc:p>
    This describes a totalDigits element.  The value attribute must take a 
    positive integer.
  </doc:p>
  <element name="totalDigits"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-totalDigits">
    <ref name="facet" />
    <attribute name="value">
      <data type="positiveInteger" />
    </attribute>
  </element>
</define>

<define name="fractionDigits">
  <doc:p>
    This describes a fractionDigits element.
  </doc:p>
  <element name="fractionDigits"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-fractionDigits">
    <ref name="numFacet" />
  </element>
</define>

<define name="length">
  <doc:p>
    This describes a length element.
  </doc:p>
  <element name="length"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-length">
    <ref name="numFacet" />
  </element>
</define>

<define name="minLength">
  <doc:p>
    This describes a minLength element.
  </doc:p>
  <element name="minLength"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-minLength">
    <ref name="numFacet" />
  </element>
</define>

<define name="maxLength">
  <doc:p>
    This describes a maxLength element.
  </doc:p>
  <element name="maxLength"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-maxLength">
    <ref name="numFacet" />
  </element>
</define-->

<define name="enumeration">
  <doc:p>
    This describes an enumeration element.
  </doc:p>
  <element name="enumeration"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-enumeration">
    <ref name="noFixedFacet" />
  </element>
</define>

<!--define name="whiteSpace">
  <doc:p>
    This describes a whiteSpace element that can take any of the permitted 
    values.
  </doc:p>
  <element name="whiteSpace"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-whiteSpace">
    <ref name="facet" />
    <attribute name="value">
      <choice>
        <value type="token">preserve</value>
        <value type="token">replace</value>
        <value type="token">collapse</value>
      </choice>
    </attribute>
  </element>
</define>

<define name="whiteSpaceReplaceOrCollapse">
  <doc:p>
    This describes a whiteSpace element that can only take the values 
    'replace' or 'collapse'.
  </doc:p>
  <element name="whiteSpace"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-whiteSpace">
    <ref name="facet" />
    <attribute name="value">
      <choice>
        <value type="token">replace</value>
        <value type="token">collapse</value>
      </choice>
    </attribute>
  </element>
</define>

<define name="whiteSpaceCollapse">
  <doc:p>
    This describes a whiteSpace element that can only take the value 
    'collapse'.
  </doc:p>
  <element name="whiteSpace"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-whiteSpace">
    <ref name="facet" />
    <attribute name="value">
      <value type="token">collapse</value>
    </attribute>
  </element>
</define>

<define name="pattern">
  <doc:p>
    This describes a pattern element.
  </doc:p>
  <element name="pattern"
        doc:href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#element-pattern">
    <ref name="noFixedFacet" />
  </element>
</define-->

</grammar>