<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xs:schema []>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:include schemaLocation="gdml_core.xsd"/>
  <xs:include schemaLocation="gdml_extensions.xsd"/>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  
  <xs:element name="define" type="defineType">
    <xs:annotation>
      <xs:documentation>Definition block of global named constants, quantitties, expressions,
        positions and rotations which may be used by name or
        by a reference in scope of the current document</xs:documentation>
    </xs:annotation>
  </xs:element>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <xs:complexType name="defineType">
    <xs:annotation>
      <xs:documentation>The global complex type is defined in order to reuse this defintion
        in derived schemas</xs:documentation>
    </xs:annotation>
    <!-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->
    
    <xs:choice maxOccurs="unbounded">
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
      
      <xs:element maxOccurs="unbounded" minOccurs="0" ref="loop"/>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
      
      <xs:element maxOccurs="unbounded" minOccurs="0" name="constant" type="IdentifiableConstantType">
	<xs:annotation>
	  <xs:documentation>Named constant</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
      
      <xs:element maxOccurs="unbounded" minOccurs="0" name="variable" type="IdentifiableVariableType">
	<xs:annotation>
	  <xs:documentation>Named variable</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
      
      <xs:element maxOccurs="unbounded" minOccurs="0" name="matrix" type="MatrixType">
	<xs:annotation>
	  <xs:documentation>Named matrix</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
      
      <xs:element maxOccurs="unbounded" minOccurs="0" name="quantity" type="IdentifiableQuantityType">
	<xs:annotation>
	  <xs:documentation>Named quantity</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
      
      <xs:element maxOccurs="unbounded" minOccurs="0" name="expression" type="IdentifiableExpressionType">
	<xs:annotation>
	  <xs:documentation>Named expression, may contain other named constants,
            quantities and expressions</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
      
      <xs:element maxOccurs="unbounded" minOccurs="0" name="position" type="positionType">
	<xs:annotation>
	  <xs:documentation>Named cartesian position, default unit mm</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
          
      <xs:element maxOccurs="unbounded" minOccurs="0" name="rotation" type="rotationType">
	<xs:annotation>
	  <xs:documentation>Named cartesian rotation, default unit radian</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

      <xs:element maxOccurs="unbounded" minOccurs="0" name="scale" type="scaleType">
	<xs:annotation>
	  <xs:documentation>Named cartesian rotation, default unit radian</xs:documentation>
	</xs:annotation>
      </xs:element>
      <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    </xs:choice>
    <!-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->
  </xs:complexType>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  
  <xs:complexType name="positionType">
    <xs:complexContent>
      <xs:restriction base="IdentifiableQuantityVectorType">
	<xs:attribute default="mm" type="xs:string" name="unit"/>
	<xs:attribute default="cartesian" type="xs:string" name="type"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  
  <xs:complexType name="rotationType">
    <xs:complexContent>
      <xs:restriction base="IdentifiableQuantityVectorType">
	<xs:attribute default="radian" type="xs:string" name="unit"/>
	<xs:attribute default="cartesian" type="xs:string" name="type"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <xs:complexType name="scaleType">
    <xs:complexContent>
      <xs:restriction base="IdentifiableQuantityVectorType">
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</xs:schema>
