<?xml version='1.0'?>
<!-- XML Schema schema for XML Schemas: Part 2: Datatypes -->
<!-- Note this schema is NOT the normative datatypes schema - - the
     prose copy in the datatypes REC is the normative version (which
     shouldn't differ from this one except for this comment and entity
     expansions, but just in case -->
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 19991216//EN" "../WD-xmlschema-1-19991217/structures.dtd" >
<schema xmlns="&XMLSchemaNS;" targetNamespace="&XMLSchemaNS;" version="$Id: datatypes.xsd,v 1.19.1.1 1999/12/17 14:03:56 ht Exp $">

  <type name="datatype" source="annotated" derivedBy="extension"
        abstract="true">
    <element ref="facet" minOccurs="0" maxOccurs="*"/>
    <attribute name="name" type="NCName" minOccurs="0">
      <annotation>
       <info>Will be restricted to required or forbidden</info>
      </annotation>
    </attribute>
    <attribute name="source" type="QName" minOccurs="1"/>
    <attribute name="final" type="derivationSet"/>
    <attribute name="abstract" type="boolean"/>
  </type>

  <type name="namedDatatype" source="datatype">
   <annotation>
    <info>This is for the top-level datatype element,
          as ref'ed in &lt;schema</info>
   </annotation>
   <attribute name="name" minOccurs="1">
    <annotation><info>Required at the top level</info></annotation>
   </attribute>   
  </type>

  <type name="anonDatatype" source="datatype">
   <annotation>
    <info>This is for the nested datatype element,
          as used in &lt;element</info>
   </annotation>
   <attribute name="name" maxOccurs="0">
    <annotation><info>Forbidden when nested</info></annotation>
   </attribute>   
  </type>

  <element name="datatype" equivClass="schemaTop" type="namedDatatype"/>

  <key name="datatype">
   <selector>schema/datatype</selector>
   <field>@name</field>
  </key>

  <type name="facet" source="annotated" derivedBy="extension">
    <attribute name="value" minOccurs="1"/>
  </type>

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

  <element name="minBound" abstract="true" equivClass="facet"/>

  <element name="minExclusive" equivClass="minBound"/>
  <element name="minInclusive" equivClass="minBound"/>

  <element name="maxBound" abstract="true" equivClass="facet"/>

  <element name="maxExclusive" equivClass="maxBound"/>
  <element name="maxInclusive" equivClass="maxBound"/>

  <type name="numFacet" source="facet" derivedBy="restriction">
   <attribute name="value" type="non-negative-integer"/>
  </type>

  <element name="precision" type="numFacet" equivClass="facet"/>
  <element name="scale" type="numFacet" equivClass="facet"/>

  <element name="length" type="numFacet" equivClass="facet"/>
  <element name="minlength" type="numFacet" equivClass="facet"/>
  <element name="maxlength" type="numFacet" equivClass="facet"/>

  <!-- the following datatype is used to limit the
       possible values for the encoding facet on
           the binary datatype -->
  <datatype name="encodings" source="NMTOKEN">
    <enumeration value="hex">
      <annotation>
        <info>each (8-bit) byte is encoded as a sequence
              of 2 hexidecimal digits</info>
      </annotation>
    </enumeration>
    <enumeration value="base64">
      <annotation>
        <info>value is encoded in Base64 as defined in the MIME RFC</info>
      </annotation>
    </enumeration>
  </datatype>

  <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>

  <element name="enumeration" equivClass="facet"/>

  <element name="pattern" equivClass="facet"/>

<!-- built-in generated datatypes -->
<!-- only has a few for now, eventually needs to have all of them -->

  <datatype name="integer" source="decimal">
    <scale value="0"/>
  </datatype>
        
  <datatype name="non-negative-integer" source="integer">
    <minInclusive value="0"/>
  </datatype>

  <datatype name="positive-integer" source="non-negative-integer">
    <minInclusive value="1"/>
  </datatype>

  <datatype name="non-positive-integer" source="integer">
    <maxInclusive value="0"/>
  </datatype>

  <datatype name="negative-integer" source="non-positive-integer">
    <maxInclusive value="-1"/>
  </datatype>

  <datatype name="date" source="recurringInstant">
    <period value="000000T2400"/>
  </datatype>

  <datatype name="time" source="recurringInstant">
    <period value="000000T2400"/>
  </datatype>
 

	<datatype name="NMTOKENS" source="string">
		<pattern value="\c+(\s\c+)*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml#NT-Nmtokens">
					pattern matches production 8 from the XML spec
				</info>
			</annotation>
		</pattern>
	</datatype>

	<datatype name="NMTOKEN" source="NMTOKENS">
		<pattern value="\c+">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml#NT-Nmtoken">
					pattern matches production 7 from the XML spec
				</info>
			</annotation>
		</pattern>
	</datatype>

	<datatype name="Name" source="NMTOKEN">
		<pattern value="\i\c*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml#NT-Name">
					pattern matches production 5 from the XML spec
				</info>
			</annotation>
		</pattern>
	</datatype>

	<datatype name="ID" source="NCName">
		<annotation>
			<info source="http://www.w3.org/TR/REC-xml#id">
				values of this datatype must be unique within
				a document
			</info>
		</annotation>
	</datatype>

	<datatype name="IDREFS" source="string">
		<pattern value="[\i-[:]][\c-[:]]*(\s[\i-[:]][\c-[:]]*)*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml#NT-Names">
     			pattern matches production 6 from the XML spec
     			(modified as required by the
     			Conformance section in
     			Namespaces in XML
                        (http://www.w3.org/TR/REC-xml-names#conformance))
				</info>
				<info source="http://www.w3.org/TR/REC-xml#idref">
					values of this datatype must have occured within
					a document as the value of some component
					of type ID
				</info>
			</annotation>
		</pattern>
	</datatype>

	<datatype name="IDREF" source="IDREFS">
		<pattern value="[\i-[:]][\c-[:]]*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml-names#NT-NCName">
					pattern matches production 4 from the Namespaces in XML spec
				</info>
				<info source="http://www.w3.org/TR/REC-xml#idref">
					values of this datatype must have occured within
					a document as the value of some component
					of type ID
				</info>
			</annotation>
		</pattern>
	</datatype>


	<datatype name="ENTITIES" source="string">
		<pattern value="[\i-[:]][\c-[:]]*(\s[\i-[:]][\c-[:]]*)*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml#NT-Names">
     			pattern matches production 6 from the XML spec
     			(modified as required by the
     			Conformance section in
     			Namespaces in XML
                        (http://www.w3.org/TR/REC-xml-names#conformance))
				</info>
				<info source="http://www.w3.org/TR/REC-xml#entname">
					values of this datatype must match the name of
					an unparsed entity declared in the schema
				</info>
			</annotation>
		</pattern>
	</datatype>

	<datatype name="ENTITY" source="ENTITIES">
		<pattern value="[\i-[:]][\c-[:]]*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml-names#NT-NCName">
					pattern matches production 4 from the Namespaces in XML spec
				</info>
				<info source="http://www.w3.org/TR/REC-xml#entname">
					values of this datatype must match the name of
					an unparsed entity declared in the schema
				</info>
			</annotation>
		</pattern>
	</datatype>

	<datatype name="NCName" source="Name">
		<pattern value="[\i-[:]][\c-[:]]*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml-names/#NT-NCName">
					pattern matches production 4 from the
					Namespaces in	XML spec
				</info>
			</annotation>
		</pattern>
	</datatype>

	<datatype name="QName" source="Name">
		<pattern value="([\i-[:]][\c-[:]]*:)?[\i-[:]][\c-[:]]*">
			<annotation>
				<info source="http://www.w3.org/TR/REC-xml-names/#NT-QName">
					pattern matches production 6 from the
					Namespaces in XML spec
				</info>
			</annotation>
		</pattern>
	</datatype>

</schema>
