<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" 
           elementFormDefault="qualified" 
		   targetNamespace="http://ns.saxonica.com/schema-component-model" 
		   xmlns:scm="http://ns.saxonica.com/schema-component-model">

  <xs:import namespace="http://www.w3.org/XML/1998/namespace"
             schemaLocation="http://www.w3.org/2001/xml.xsd"/>

  <xs:element name="schema">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="scm:element"/>
        <xs:element ref="scm:attribute"/>
        <xs:element ref="scm:complexType"/>
        <xs:element ref="scm:simpleType"/>
		<xs:element ref="scm:attributeGroup"/>
		<xs:element ref="scm:modelGroupDefinition"/>
		<xs:element ref="scm:notation"/>
		<xs:element ref="scm:wildcard"/>
        <xs:element ref="scm:unique"/>
        <xs:element ref="scm:key"/>
        <xs:element ref="scm:keyref"/>
      </xs:choice>
      <xs:attribute name="generatedAt" type="xs:dateTime"/>
      <xs:attribute name="xsdVersion" type="scm:xsdVersionType"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="attribute">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an attribute declaration schema component (3.2.1). 
      The properties are represented as follows:
      {name}                 The name attribute
      {target namespace}     The targetNamespace attribute
      {type definition}      The type attribute
      {scope}.{variety}      The global attribute; 
      {scope}.{parent}       The containingComplexType attribute
      {value constraint}     The "default" attribute (holding the lexical form of the value)
	                         or the child element "fixed" (holding the typed value)
      {annotation}           Not retained in SCM                  
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
	  <xs:sequence>
	  	<xs:element ref="scm:fixed" minOccurs="0" maxOccurs="1"/>
	  </xs:sequence>
      <xs:attribute name="containingComplexType" type="xs:IDREF"/>
      <xs:attribute name="default" type="xs:string"/>
      <xs:attribute name="global" use="required" type="xs:boolean"/>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" use="required" type="xs:NCName"/>
      <xs:attribute name="targetNamespace" type="scm:uriType"/>
      <xs:attribute name="type" use="required" type="scm:typeReferenceType"/>
      <xs:attribute name="inheritable" use="required" type="xs:boolean"/> 
    </xs:complexType>
  </xs:element>  

  <xs:element name="element">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an element declaration schema component (3.3.1). 
      The properties are represented as follows:
      {annotations}          Not retained in SCM  
      {name}                 The name attribute
      {target namespace}     The targetNamespace attribute
      {type definition}      The type attribute
      {type table}           The sequence of scm:alternativeType elements. The {default type definition}
                             is the last scm:alternativeType in the sequence, if it has a condition of "true()".
      {scope}.{variety}      The global attribute; 
      {scope}.{parent}       The containingComplexType attribute
      {value constraint}     The attribute "default" (holding the lexical form of the value)
	                         and the child element "fixed" (holding the typed value)
      {nillable}             The nillable attribute
      {identity-constraint definitions}
                             The scm:unique, scm:key, and scm:keyref elements referenced by the 
                             contained scm:identityConstraint elements
      {substitution group affiliations}
                             The contained scm:substitutionGroupAffiliation elements                       
      {substitution group exclusions}
                             The final attribute 
      {disallowed substitutions}
                             The block attribute
      {abstract}             The abstract attribute                                  
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
	  <xs:sequence>
	  	<xs:element ref="scm:substitutionGroupAffiliation" minOccurs="0" maxOccurs="unbounded"/>
	  	<xs:element ref="scm:alternativeType" minOccurs="0" maxOccurs="unbounded"/>
	  	<xs:element ref="scm:identityConstraint" minOccurs="0" maxOccurs="unbounded"/>
		<xs:element ref="scm:fixed" minOccurs="0" maxOccurs="1"/>
	  </xs:sequence>
      <xs:attribute name="abstract" use="required" type="xs:boolean"/>
	  <xs:attribute name="block" use="optional" type="scm:blockType"/>
      <xs:attribute name="containingComplexType" use="optional" type="xs:IDREF"/>
	  <xs:attribute name="default" use="optional" type="xs:string"/>
	  <xs:attribute name="final" use="optional" type="scm:finalType"/>
      <xs:attribute name="global" use="required" type="xs:boolean"/>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" use="required" type="xs:NCName"/>
      <xs:attribute name="nillable" use="required" type="xs:boolean"/>
      <xs:attribute name="targetNamespace" use="optional" type="scm:uriType"/>
      <xs:attribute name="type" use="required" type="scm:typeReferenceType"/>
	  <xs:assert test="not(@default and scm:fixed)" vc:minVersion="1.1"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="substitutionGroupAffiliation">
    <xs:annotation>
      <xs:documentation>
      Represents the participation of the containing element in the substitution group of the referenced element
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
	  <xs:attribute name="ref" use="required" type="xs:IDREF"/>
	</xs:complexType>
  </xs:element>
  
  <xs:element name="alternativeType">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a type alternative schema component (3.12.1). 
      The properties are represented as follows:
      {annotations}         Not retained in SCM  
      {test}                The test attribute represents the {expression}; the {namespace bindings} and
                            {base URI} are represented by the in-scope namespace bindings and base URI of the
                            scm:alternativeType element itself. The {default namespace} property is 
							represented by the defaultNamespace property.
      {type definition}     The type attribute
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
	  <xs:attribute name="type" use="required" type="scm:typeReferenceType"/>
	  <xs:attribute name="test" use="required" type="scm:xpathExpressionType"/>
	  <xs:attribute name="defaultNamespace" use="required" type="scm:uriType"/>
	  <xs:attribute ref="xml:base" use="optional"/>
	</xs:complexType>
  </xs:element>
  
  <xs:element name="identityConstraint">
    <xs:annotation>
        <xs:documentation>
            A reference to an identityConstraint in an element declaration. In XSD 1.1,
            identity constraints can effectively be shared between multiple element declarations
            by use of the "ref" attribute. In SCM, the identity constraints are represented
            as first-class components, referenced from all the element declarations that use
            them; none of these is considered to be the primary "owner" or "container" of the
            constraint.
        </xs:documentation>
    </xs:annotation>
    <xs:complexType>
	  <xs:attribute name="ref" use="required" type="xs:IDREF"/>
	  <xs:attribute ref="xml:base" use="optional"/>
	</xs:complexType>
  </xs:element>  

  <xs:element name="complexType">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a complex type definition schema component (3.4.1). 
      The properties are represented as follows:
      {annotations}          Not retained in SCM  
      {name}                 The name attribute
      {target namespace}     The targetNamespace attribute
      {base type definition} The base attribute
      {final}                The final attribute 
      {context}              Not retained in SCM
      {derivation method}    The derivationMethod attribute
      {abstract}             The abstract attribute
      {attribute uses}       The contained scm:attributeUse elements
      {attribute wildcard}   The contained scm:attributeWildcard element
      {content type}.{variety}
                             The variety attribute
      {content type}.{particle}
                             The contained scm:abstractParticle element 
                             (elementParticle, elementWildcard, or modelGroupParticle)
      {content type}.{open content}.{mode}
                             The mode attribute of the child scm:openContent element
      {content type}.{open content}.{wildcard}                       
                             The scm:wildcard referenced by the child cm:openContent element
      {content type}.{simple type definition}
                             The simpleType attribute                                               
      {prohibited substitutions}
                             The block attribute
                          
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" ref="scm:openContent"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="scm:attributeUse"/>
        <xs:element minOccurs="0" maxOccurs="1" ref="scm:attributeWildcard"/>
        <xs:element minOccurs="0" ref="scm:abstractParticle"/>
        <xs:element minOccurs="0" ref="scm:finiteStateMachine"/>
		<xs:element minOccurs="0" maxOccurs="unbounded" ref="scm:assertion"/>
      </xs:sequence>
      <xs:attribute name="abstract" use="required" type="xs:boolean"/>
      <xs:attribute name="base" use="required" type="scm:typeReferenceType"/>
      <xs:attribute name="derivationMethod" use="required" type="scm:derivationMethodType"/>
      <xs:attribute name="block" use="optional" type="scm:blockType"/>
      <xs:attribute name="final" use="optional" type="scm:finalType"/>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" type="xs:NCName"/>
      <xs:attribute name="simpleType" type="scm:typeReferenceType"/>
      <xs:attribute name="targetNamespace" type="scm:uriType"/>
      <xs:attribute name="variety" use="required" type="scm:complexVarietyType"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="openContent">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an Open Content property record (3.4.1). 
      The properties are represented as follows:
      {mode}            The mode attribute  
      {wildcard}        The wildcard child element  
      </xs:documentation>
    </xs:annotation> 
    <xs:complexType>
      <xs:attribute name="mode" type="scm:openContentModeType"/>
      <xs:attribute name="wildcard" type="xs:IDREF"/>  
    </xs:complexType>
  </xs:element>

  <xs:element name="attributeUse">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an attribute use schema component (3.5.1). 
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {required}               The required attribute
      {attribute declaration}  The ref attribute
      {value constraint}       The "default" attributes (containing the lexical form of the value)
	                           or the child element "fixed" (containing the typed value)      
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
	  	<xs:element ref="scm:fixed" minOccurs="0" maxOccurs="1"/>
	  </xs:sequence>
      <xs:attribute name="default" type="xs:string"/>
      <xs:attribute name="ref" use="required" type="xs:IDREF"/>
      <xs:attribute name="required" use="required" type="xs:boolean"/>
      <xs:attribute name="inheritable" use="required" type="xs:boolean"/>      
    </xs:complexType>
  </xs:element>
  
  <xs:element name="attributeWildcard">
    <xs:annotation>
      <xs:documentation>
      Represents an attribute wildcard
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="ref" use="required" type="xs:IDREF"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="fixed" type="scm:typedValueType"/>  

  <xs:element name="abstractParticle" abstract="true" type="scm:abstractParticleType">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a Particle Schema Component (3.9.1). There are three concrete elements
      in the substitution group: elementParticle, elementWildcard, and modelGroupParticle
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {min Occurs}             The minOccurs attribute
      {max Occurs}             The maxOccurs attribute
      {term}                   depends on the concrete subtype   
      </xs:documentation>
    </xs:annotation>
  </xs:element>    

  <xs:element name="elementWildcard" substitutionGroup="scm:abstractParticle">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a Particle Schema Component (3.9.1) whose {term} is a wildcard
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {min Occurs}             The minOccurs attribute
      {max Occurs}             The maxOccurs attribute
      {term}                   The scm:wildcard element referenced by the ref attribute  
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="scm:abstractParticleType">
          <xs:attribute name="ref" use="required" type="xs:IDREF"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="wildcard">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a Wildcard Schema Component (3.10.1) representing either an element wildcard (xs:any)
      or an attribute wildcard (xs:anyAttribute)
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {namespace constraint}.{variety}
                               The constraint attribute
      {namespace constraint}.{namespaces}
                               The namespaces attribute
      {process contents}       The processContents attribute         
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="constraint" use="required" type="xs:NCName"/>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="namespaces" type="scm:namespaceListType"/>
      <xs:attribute name="processContents" use="required" type="scm:processContentsType"/>
      <xs:attribute name="notQName" use="optional" type="scm:notQNameListType"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="finiteStateMachine">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="scm:state"/>
      </xs:sequence>
      <xs:attribute name="initialState" use="required" type="xs:integer"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="state">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="scm:edge"/>
      </xs:sequence>
      <xs:attribute name="afterMax" type="xs:integer"/>
      <xs:attribute name="final" type="xs:boolean"/>
      <xs:attribute name="maxOccurs" type="scm:maxOccursType"/>
      <xs:attribute name="minOccurs" type="xs:integer"/>
      <xs:attribute name="nr" use="required" type="xs:integer"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="edge">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="term" use="required" type="xs:IDREF"/>
      <xs:attribute name="to" use="required" type="xs:integer"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="simpleType">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a simple type definition schema component (3.16.1). 
      The properties are represented as follows:
      {annotations}          Not retained in SCM  
      {name}                 The name attribute
      {target namespace}     The targetNamespace attribute
      {final}                The final attribute 
      {context}              Not retained in SCM      
      {base type definition} The base attribute
      {facets}               The contained scm:abstractFacet elements
      {fundamental facets}   Not represented in SCM
      {variety}              The variety attribute
      {primitive type definition}
                             The primitiveType attribute
      {item type definition} The itemType attribute 
      {member type definitions}
                             The memberTypes attribute                       
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="scm:abstractFacet"/>
      </xs:sequence>
      <xs:attribute name="base" use="required" type="scm:typeReferenceType"/>
      <xs:attribute name="final" use="optional" type="scm:finalType"/>
      <xs:attribute name="id" use="required" type="xs:ID"/>
	  <xs:attribute name="itemType" use="optional" type="scm:typeReferenceType"/>
	  <xs:attribute name="memberTypes" use="optional" type="scm:typeReferenceListType"/>
      <xs:attribute name="name" type="xs:NCName"/>
      <xs:attribute name="primitiveType" use="optional" type="scm:builtInTypeReferenceType"/>
      <xs:attribute name="targetNamespace" type="scm:uriType"/>
      <xs:attribute name="variety" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="abstractFacet" abstract="true">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a Constraining Facet schema component (Part 2, 4.3)
      </xs:documentation>
    </xs:annotation>
  </xs:element>    

  <xs:element name="whiteSpace" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the whiteSpace schema component (Part 2, 4.3.6.1). 
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute
      {fixed}                The fixed attribute  
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="scm:whitespaceType"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="assert" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to one assertion in the assertions facet schema component (Part 2, 4.3.11.1). 
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The contained scm assertion element
      {fixed}                The fixed attribute        
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="scm:assertion" minOccurs="1" maxOccurs="1"/>
      </xs:sequence>  
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>  

  <xs:element name="totalDigits" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the totalDigits schema component (Part 2, 4.3.11.1). 
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute
      {fixed}                The fixed attribute        
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="xs:positiveInteger"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="fractionDigits" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the fractionDigits schema component (Part 2, 4.3.11.1). 
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute
      {fixed}                The fixed attribute       
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="xs:nonNegativeInteger"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="enumeration" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to (part of) the enumeration schema component (Part 2, 4.3.11.1).
      Each value in the {value} of the enumeration component is represented by a separate
      scm:enumeration element. 
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute (as a lexical representation of the value)
      The attribute namespaceSensitive is set to true if the value is (or contains) a QName or NOTATION
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required"/>
      <xs:attribute name="namespaceSensitive" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="pattern" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the pattern schema component (Part 2, 4.3.4.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute     
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="xs:string"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="minInclusive" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the minInclusive schema component (Part 2, 4.3.10.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute (as a lexical representation of the value)
      {fixed}                The fixed attribute      
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="maxInclusive" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the maxInclusive schema component (Part 2, 4.3.8.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute (as a lexical representation of the value)
      {fixed}                The fixed attribute       
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="minExclusive" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the minExclusive schema component (Part 2, 4.3.9.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute (as a lexical representation of the value)
      {fixed}                The fixed attribute      
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="maxExclusive" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the maxExclusive schema component (Part 2, 4.3.8.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute (as a lexical representation of the value)
      {fixed}                The fixed attribute       
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>  

  <xs:element name="length" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the length schema component (Part 2, 4.3.1.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute 
      {fixed}                The fixed attribute       
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="xs:nonNegativeInteger"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="minLength" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the minLength schema component (Part 2, 4.3.2.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute 
      {fixed}                The fixed attribute       
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="xs:nonNegativeInteger"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="maxLength" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the maxLength schema component (Part 2, 4.3.3.1).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute 
      {fixed}                The fixed attribute
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="xs:nonNegativeInteger"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="explicitTimezone" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the explicitTimezone schema component (New in XSD 1.1, Part 2, 4.3.16).
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute 
      {fixed}                The fixed attribute
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required" type="scm:explicitTimezoneType"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="minScale" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the minScale schema component.
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute (as a lexical representation of the value)
      {fixed}                The fixed attribute      
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="maxScale" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the maxScale schema component.
      The properties are represented as follows:
      {annotations}          Not retained in SCM
      {value}                The value attribute (as a lexical representation of the value)
      {fixed}                The fixed attribute       
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="value" use="required"/>
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="preprocess" substitutionGroup="scm:abstractFacet">
    <xs:annotation>
      <xs:documentation>
      Corresponds to the Saxon-specific preprocess facet schema component. 
      The first assertion element represents the preprocessing action to be performed; 
      the second (if present) represents the reverse action.
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="scm:assertion" minOccurs="1" maxOccurs="2"/>
      </xs:sequence>  
      <xs:attribute name="fixed" use="optional" type="xs:boolean" default="false"/>
    </xs:complexType>
  </xs:element>      

  <xs:element name="elementParticle" substitutionGroup="scm:abstractParticle">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a Particle Schema Component (3.9.1) whose {term} is an element declaration
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {min Occurs}             The minOccurs attribute
      {max Occurs}             The maxOccurs attribute
      {term}                   The element declaration referenced by the ref attribute   
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="scm:abstractParticleType">
          <xs:attribute name="ref" use="required" type="xs:IDREF"/>
        </xs:extension>
      </xs:complexContent>  
    </xs:complexType>
  </xs:element>

  <xs:element name="modelGroupParticle" substitutionGroup="scm:abstractParticle">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a Particle Schema Component (3.9.1) whose {term} is a model group.
      In the W3C Schema Component Model, named model groups exist as Model Group Definition
      components, but they are never referenced, because the references are fully expanded
      (recursively). In this model, the references remain as references to scm:modelGroupDefinition
      elements.
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {min Occurs}             The minOccurs attribute
      {max Occurs}             The maxOccurs attribute
      {term}                   Either the contained sequence of scm:abstractModelGroup elements,
                               or the scm:modelGroupDefinition referenced by the ref attribute        
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="scm:abstractParticleType">
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" ref="scm:abstractModelGroup"/>
          </xs:sequence>
          <xs:attribute name="ref" type="xs:IDREF"/>  
        </xs:extension>
      </xs:complexContent>      
    </xs:complexType>
  </xs:element>

  <xs:element name="abstractModelGroup" abstract="true">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a ModelGroup component (3.8.1).
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {compositor}             The specific element name: all, choice, or sequence
      {particles}              The contained scm:abstractParticle elements 
                               (elementParticle, elementWildcard, or modelGroupParticle)  
      </xs:documentation>
    </xs:annotation>  
   <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="scm:abstractParticle"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="sequence" substitutionGroup="scm:abstractModelGroup">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a ModelGroup component (3.8.1) whose compositor is "sequence"
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {compositor}             Always "sequence"
      {particles}              The contained scm:abstractParticle elements 
                               (elementParticle, elementWildcard, or modelGroupParticle)       
      </xs:documentation>
    </xs:annotation>
  </xs:element>    
 
  <xs:element name="choice" substitutionGroup="scm:abstractModelGroup">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a ModelGroup component (3.8.1) whose compositor is "choice"
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {compositor}             Always "choice"
      {particles}              The contained scm:abstractParticle elements 
                               (elementParticle, elementWildcard, or modelGroupParticle)       
      </xs:documentation>
    </xs:annotation>
  </xs:element>

  <xs:element name="all" substitutionGroup="scm:abstractModelGroup">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a ModelGroup component (3.8.1) whose compositor is "all"
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {compositor}             Always "all"
      {particles}              The contained scm:abstractParticle elements 
                               (elementParticle, elementWildcard, or modelGroupParticle)       
      </xs:documentation>
    </xs:annotation>
  </xs:element>  
 
  <xs:element name="key" type="scm:identityConstraintType">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an IdentityConstraint Definition component (3.11.1) whose category is "key"
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {name}                   The name attribute
      {target namespace}       The targetNamespace attribute
      {identity-constraint category}
                               Always "key"
      {selector}               The contained scm:selector element
      {fields}                 The sequence of contained scm:field elements                         
      </xs:documentation>
    </xs:annotation>
  </xs:element>

  <xs:element name="unique" type="scm:identityConstraintType">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an IdentityConstraint Definition component (3.11.1) whose category is "unique"
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {name}                   The name attribute
      {target namespace}       The targetNamespace attribute
      {identity-constraint category}
                               Always "unique"
      {selector}               The contained scm:selector element
      {fields}                 The sequence of contained scm:field elements      
      </xs:documentation>
    </xs:annotation>
  </xs:element>

  <xs:element name="keyref" type="scm:identityConstraintType">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an IdentityConstraint Definition component (3.11.1) whose category is "keyref"
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {name}                   The name attribute
      {target namespace}       The targetNamespace attribute
      {identity-constraint category}
                               Always "keyref"
      {selector}               The contained scm:selector element
      {fields}                 The sequence of contained scm:field elements
      {referenced key}         The scm:key or scm:unique element referenced by the key attribute
      </xs:documentation>
    </xs:annotation>
  </xs:element>

  <xs:element name="selector" type="scm:xpathContainerType">
    <xs:annotation>
      <xs:documentation>
      Represents the {selector} property of an Identity-Constraint Definition (3.11.1)
      </xs:documentation>
    </xs:annotation>
  </xs:element>
  

  <xs:element name="field" type="scm:xpathContainerType">
    <xs:annotation>
      <xs:documentation>
      Represents one property record within the {fields} property of an Identity-Constraint Definition (3.11.1)
      </xs:documentation>
    </xs:annotation>
  </xs:element>

  <xs:element name="assertion">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
	  <xs:attribute name="test" use="required" type="scm:xpathExpressionType"/>
	  <xs:attribute name="defaultNamespace" use="required" type="scm:uriType"/>
	  <xs:attribute ref="xml:base" use="optional"/>
	</xs:complexType>
  </xs:element>

  <xs:element name="attributeGroup">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an Attribute Group Definition Schema Component (3.6.1). Note that attribute group
      definitions are not referenced from any other components in the schema (their expansion is included in 
      complex type definition components).
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {name}                   The name attribute
      {target namespace}       The targetNamespace attribute
      {attribute uses}         The contained scm:attributeUse elements
      {attribute wildcard}     The contained scm:attributeWildcard element
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="scm:attributeUse"/>
        <xs:element minOccurs="0" maxOccurs="1" ref="scm:attributeWildcard"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" type="xs:NCName"/>
      <xs:attribute name="targetNamespace" type="scm:uriType"/>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="modelGroupDefinition">
    <xs:annotation>
      <xs:documentation>
      Corresponds to a Model Group Definition Schema Component (3.7.1). In the W3C model, model group
      definitions are not referenced from any other components in the schema (their expansion is included in 
      complex type definition components). In this model, however, an scm:modeGroupDefinition can be referenced
      from an scm:modelGroupReference.
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {name}                   The name attribute
      {target namespace}       The targetNamespace attribute
      {model group}            The contained sequence of scm:abstractParticle elements. This is implicitly
                               treated as a sequence model group.
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="scm:abstractParticle"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" type="xs:NCName"/>
      <xs:attribute name="targetNamespace" type="scm:uriType"/>
    </xs:complexType>
  </xs:element>  
  
  <xs:element name="notation">
    <xs:annotation>
      <xs:documentation>
      Corresponds to an Notation Declaration Schema Component (3.14.1). 
      The properties are represented as follows:
      {annotations}            Not retained in SCM  
      {name}                   The name attribute
      {target namespace}       The targetNamespace attribute
      {system identifier}      The systemId attribute
      {public identifier}      The publicId attribute
      </xs:documentation>
    </xs:annotation>  
    <xs:complexType>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" type="xs:NCName"/>
      <xs:attribute name="targetNamespace" type="scm:uriType"/>
      <xs:attribute name="systemId" type="scm:uriType"/>
      <xs:attribute name="publicId" type="xs:string"/>
    </xs:complexType>
  </xs:element>  

  <xs:complexType name="abstractParticleType" abstract="true">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:attribute name="maxOccurs" use="required" type="scm:maxOccursType"/>
    <xs:attribute name="minOccurs" use="required" type="xs:nonNegativeInteger"/>
  </xs:complexType>	  

  <xs:complexType name="identityConstraintType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:sequence>
	  <xs:element ref="scm:selector"/>
	  <xs:element ref="scm:field" minOccurs="1" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" use="required" type="xs:ID"/>
    <xs:attribute name="name" use="required" type="xs:NCName"/>
    <xs:attribute name="targetNamespace" use="optional" type="scm:uriType"/>
    <xs:attribute name="key" use="optional" type="xs:IDREF"/>
  </xs:complexType>

  <xs:complexType name="typedValueType">
    <xs:annotation>
	  <xs:documentation>
	  </xs:documentation>
	</xs:annotation>
	<xs:sequence>
	  <xs:element name="item" minOccurs="0" maxOccurs="unbounded">
	  	<xs:complexType>
		  <xs:attribute name="type" type="scm:builtInTypeReferenceType" use="required"/>
		  <xs:attribute name="value" type="xs:string" use="required"/>
		  <xs:attribute name="namespace" type="scm:uriType" use="optional"/>
		</xs:complexType>
	  </xs:element>
	</xs:sequence>
  </xs:complexType>

  <xs:complexType name="xpathContainerType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:attribute name="xpath" use="required" type="scm:xpathExpressionType"/>
    <xs:attribute name="defaultNamespace" use="required" type="scm:uriType"/>
    <xs:attribute ref="xml:base" use="optional"/>
  </xs:complexType>

  <xs:simpleType name="blockType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:list itemType="scm:derivationMethodType"/>
  </xs:simpleType>

  <xs:simpleType name="builtInTypeReferenceType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:string">
      <xs:pattern value="#[a-zA-Z0-9]+"/>
		<!-- TODO: enumerate the permitted values -->
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="clarkNameType">
     <xs:annotation>
      <xs:documentation>
        A qualified QName in Clark notation: {uri}local
      </xs:documentation>
    </xs:annotation> 
    <xs:restriction base="xs:string">
	  <xs:pattern value="\{[^{}]*\}\i\c*"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="complexVarietyType">
     <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation> 
    <xs:restriction base="xs:NCName">
	  <xs:enumeration value="empty"/>
	  <xs:enumeration value="simple"/>
	  <xs:enumeration value="mixed"/>
	  <xs:enumeration value="element-only"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="derivationMethodType">
     <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation> 
    <xs:restriction base="xs:NCName">
	  <xs:enumeration value="extension"/>
	  <xs:enumeration value="restriction"/>
      <xs:enumeration value="substitution"/>
	  <xs:enumeration value="list"/>
	  <xs:enumeration value="union"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="explicitTimezoneType">
     <xs:annotation>
      <xs:documentation>
      Defines the permitted values of the explicitTimezone facet introduced in XSD 1.1
      </xs:documentation>
    </xs:annotation> 
    <xs:restriction base="xs:NCName">
	  <xs:enumeration value="required"/>
	  <xs:enumeration value="prohibited"/>
      <xs:enumeration value="optional"/>
    </xs:restriction>
  </xs:simpleType>  

  <xs:simpleType name="finalType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:list itemType="scm:derivationMethodType"/>
  </xs:simpleType>

  <xs:simpleType name="maxOccursType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:union memberTypes="xs:nonNegativeInteger scm:unboundedType"/>
  </xs:simpleType>
  
  <xs:simpleType name="namespaceListType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:list itemType="scm:namespaceType"/>
  </xs:simpleType>
  
  <xs:simpleType name="namespaceType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:union memberTypes="scm:pseudoNamespaceType scm:uriType"/>
  </xs:simpleType>    
  
  <xs:simpleType name="notQNameListType">
    <xs:annotation>
      <xs:documentation>
      A list of tokens each of which is either ##defined, ##definedSibling, or a QName in Clark notation
      </xs:documentation>
    </xs:annotation>  
    <xs:list itemType="scm:notQNameType"/>
  </xs:simpleType>
  
  <xs:simpleType name="notQNameType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:union memberTypes="scm:pseudoQNameType scm:clarkNameType xs:NCName"/>
  </xs:simpleType>     
  
  <xs:simpleType name="openContentModeType">
    <xs:annotation>
      <xs:documentation>
      Represents the open content mode (XSD 1.1): either "suffix" or "interleave"
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:NCName">
	  <xs:enumeration value="suffix"/>
	  <xs:enumeration value="interleave"/>
    </xs:restriction>
  </xs:simpleType>    

  <xs:simpleType name="processContentsType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:NCName">
	  <xs:enumeration value="strict"/>
	  <xs:enumeration value="lax"/>
	  <xs:enumeration value="skip"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="pseudoNamespaceType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:string">
	  <xs:enumeration value="##any"/>    
	  <xs:enumeration value="##absent"/>
	  <xs:enumeration value="##defaultNamespace"/>	  	  
	  <xs:enumeration value="##local"/>	  
	  <xs:enumeration value="##other"/>
	  <xs:enumeration value="##targetNamespace"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="pseudoQNameType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:string">
	  <xs:enumeration value="##defined"/>    
	  <xs:enumeration value="##definedSibling"/>
    </xs:restriction>
  </xs:simpleType>  

  <xs:simpleType name="typeReferenceType">
    <xs:annotation>
      <xs:documentation>
        A reference to a type, which may either be a built-in type (written for example #string or #NCName)
        or a user-defined type represented by its ID value.
      </xs:documentation>
    </xs:annotation>  
    <xs:union memberTypes="scm:builtInTypeReferenceType xs:IDREF"/>
  </xs:simpleType>

  <xs:simpleType name="typeReferenceListType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:list itemType="scm:typeReferenceType"/>
  </xs:simpleType>

  <xs:simpleType name="unboundedType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:NCName">
	<xs:enumeration value="unbounded"/>
    </xs:restriction>
 </xs:simpleType>
 
 <xs:simpleType name="uriType">
   <xs:annotation>
     <xs:documentation>
	 We don't use xs:anyURI because we don't want to be prescriptive about namespace URIs
	 </xs:documentation>
   </xs:annotation>
   <xs:restriction base="xs:token">
     <xs:pattern value="[^\s\r\n\t]*"/>
   </xs:restriction>
 </xs:simpleType> 

  <xs:simpleType name="whitespaceType">
    <xs:annotation>
      <xs:documentation>
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:NCName">
      <xs:enumeration value="preserve"/>
      <xs:enumeration value="replace"/>
      <xs:enumeration value="collapse"/>
    </xs:restriction>
 </xs:simpleType> 
    
  <xs:simpleType name="xpathExpressionType">
    <xs:annotation>
      <xs:documentation>
        An XPath expression
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:string">
	<xs:pattern value=".+"/>
    </xs:restriction>
  </xs:simpleType> 
  
  <xs:simpleType name="xsdVersionType">
    <xs:annotation>
      <xs:documentation>
        A string representing a version of the XSD language: either "1.0" or "1.1"
      </xs:documentation>
    </xs:annotation>  
    <xs:restriction base="xs:string">
	  <xs:enumeration value="1.0"/>
	  <xs:enumeration value="1.1"/>
    </xs:restriction>
  </xs:simpleType>  




</xs:schema>
