<?xml version='1.0'?>
<!-- $Id: datatypes.xsd,v 1.1 1999/09/24 18:20:06 hugo Exp $ -->
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 19990923//EN" "../structures/structures.dtd" >
<schema xmlns='http://www.w3.org/1999/09/23-xmlschema/' targetNS='http://www.w3.org/1999/09/23-xmlschema/datatypes/' version='0.4'>

  <element name='datatype'>
     <archetype order='all'>
        <element ref='basetype'/>
        <element archRef='maxBound' minOccurs='0'/>
        <element archRef='minBound' minOccurs='0'/>
        <element ref='minAbsoluteValue' minOccurs='0'/>
        <element ref='maxAbsoluteValue' minOccurs='0'/>
        <element ref='maxInclusive' minOccurs='0'/>
        <element ref='minInclusive' minOccurs='0'/>
        <element ref='precision' minOccurs='0'/>
        <element ref='scale' minOccurs='0'/>
        <element ref='length' minOccurs='0'/>
        <element ref='maxLength' minOccurs='0'/>
        <element ref='enumeration' minOccurs='0'/>
        <element ref='lexicalRepresentation' minOccurs='0'/>
        <element ref='encoding' minOccurs='0'/>
        <attribute name='name' type='NMTOKEN' minOccurs='1'/>
        <attribute name='export' type='boolean' default='true'/>
     </archetype>
  </element>

  <element name='basetype'>
     <archetype content='empty'>
        <attribute name='name' type='NMTOKEN' minOccurs='1'/>
        <attribute name='schemaAbbrev' type='NMTOKEN'/>
        <attribute name='schemaName' type='uri'/>
     </archetype>
  </element>

  <!-- these are here to bridge between the content model above
       and the elements below -->
  <archetype name='minBound'/>
  <archetype name='maxBound'/>

  <!-- these can only be applied when the base type is 'real'
       and must be used in concert with one another -->
  <element name='minAbsoluteValue' type='real'>
  <element name='maxAbsoluteValue' type='real'>
  
  <!-- the true datatype of the four following depends on the basetype -->
  <element name='maxExclusive' type='string'>
     <archetype>
       <refines name='maxBound'/>
     </archetype>
  </element>
  <element name='maxInclusive' type='string'>
     <archetype>
       <refines name='maxBound'/>
     </archetype>
  </element>
  <element name='minExclusive' type='string'>
     <archetype>
       <refines name='minBound'/>
     </archetype>
  </element>
  <element name='minInclusive' type='string'>
     <archetype>
       <refines name='minBound'/>
     </archetype>
  </element>

  <element name='precision' type='integer'/>
  <element name='scale' type='integer'/>

  <element name='length' type='integer'/>
  <element name='maxLength' type='integer'/>

  <!-- the following datatype is used to limit the
       possible values for the encoding facet on
	   the binary datatype -->
  <datatype name='encodings'>
     <basetype name='NMTOKEN'/>
	 <enumeration>
	    <literal>hex</literal>
		<literal>base64</literal>
     <enumeration>
  </datatype>
  <element name='encoding' type='encodings'/>

  <element name='period' type='timeDuration'/>

  <element name='enumeration'>
    <archetype>
       <element ref='literal' minOccurs='1' maxOccurs='*'/>
    </archetype>
  </element>
  <!-- the true datatype of the following depends on the basetype -->
  <element name='literal' type='string'/>

  <element name='lexicalRepresentation'>
     <archetype>
        <element ref='lexical' minOccurs='1' maxOccurs='*'/>
     </archetype>
  </element>
    <!-- the true datatype of the following depends on the basetype -->
  <element name='lexical' type='string'/>

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

  <datatype name='integer'>
    <basetype name='decimal'/>
    <scale>0</scale>
  </datatype>
	
  <datatype name='non-negative-integer'>
    <basetype name='integer'/>
    <minInclusive>0</minInclusive>
  </datatype>

  <datatype name='positive-integer'>
    <basetype name='non-negative-integer'/>
    <minInclusive>1</minInclusive>
  </datatype>

  <datatype name='non-positive-integer'>
    <basetype name='integer'/>
    <maxInclusive>0</maxInclusive>
  </datatype>

  <datatype name='negative-integer'>
    <basetype name='non-positive-integer'/>
    <maxInclusive>-1</maxInclusive>
  </datatype>

  <datatype name='date'>
    <basetype name='recurringInstant'/>
    <period>000000T2400</period>
  </datatype>

  <datatype name='time'>
    <basetype name='recurringInstant'/>
    <period>000000T2400</period>
  </datatype>
</schema>
