<?xml version="1.0" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://akaxiso.sourceforge.jp/osixaka2/2.0-beta3"
	xmlns:osx="http://akaxiso.sourceforge.jp/osixaka2/2.0-beta3"
	elementFormDefault="qualified" >

  <!-- for preference file. -->
  <xs:element name="preference" type="osx:preference"/>

  <!-- for preference written in schema document. -->
  <xs:element name="include" type="osx:include"/>
  <xs:element name="xiso_include" type="osx:include"/>
  <xs:element name="ximpl_include" type="osx:include"/>
  <xs:element name="namespace">
    <xs:complexType>
      <xs:attribute name="prefix" type="xs:string" use="required"/>
      <xs:attribute name="uri" type="xs:anyURI"/>
    </xs:complexType>
  </xs:element>

  <xs:attribute name="leaf" type="xs:token"/>
  <xs:attribute name="typedef_of" type="xs:token"/>
  <xs:attribute name="classname" type="xs:token"/>
  <xs:attribute name="resolve" type="xs:QName"/>

  <xs:attribute name="presence" type="xs:NCName"/>

  <xs:complexType name="internal">
    <xs:all>
      <xs:element name="builtins" type="osx:builtins"/>
      <xs:element name="imports" type="osx:imports"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="preference">
    <xs:annotation>root of preference document. </xs:annotation>
    <xs:sequence>
      <xs:element name="format" type="osx:format"/>
      <xs:element name="substitutions" type="osx:substitutions"/>
      <xs:element name="escapes" type="osx:escapes"/>
      <xs:element name="directives" type="osx:directives"/>
      <xs:element name="internal" type="osx:internal" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="include">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="system" type="xs:boolean" default="false"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>


  <xs:complexType name="format">
    <xs:sequence>
      <xs:element name="member" type="osx:member_type"/>
      <xs:element name="array" type="osx:array_type"/>
      <xs:element name="choice" type="osx:container_type"/>
      <xs:element name="simplecontent" type="osx:simplecontent_value_name"/>
      <xs:element name="particle_item" type="osx:member_type"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="container_type">
    <xs:attribute name="container" type="xs:string" use="required"/>
  </xs:complexType>

  <xs:complexType name="simplecontent_value_name">
    <xs:attribute name="valuename" type="xs:string" use="required"/>
  </xs:complexType>

  <xs:complexType name="array_type">
    <xs:attribute name="container" type="xs:string" use="required"/>
    <xs:attribute name="prefix" type="xs:string" use="required"/>
    <xs:attribute name="suffix" type="xs:string" use="required"/>
  </xs:complexType>

  <xs:complexType name="member_type">
    <xs:attribute name="prefix" type="xs:string" use="required"/>
    <xs:attribute name="suffix" type="xs:string" use="required"/>
  </xs:complexType>


  <xs:complexType name="substitutions">
    <xs:sequence>
      <xs:element name="substitution" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType osx:classname="substitution">
          <xs:attribute name="original" type="xs:string" use="required"/>
          <xs:attribute name="substituted" type="xs:string" use="required"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="escapes">
    <xs:sequence>
      <xs:element name="escape" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType osx:classname="escape">
          <xs:attribute name="to_escape" type="xs:string" use="required"/>
          <xs:attribute name="escaped" type="xs:string" use="required"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="builtins">
    <xs:sequence>
      <xs:element name="type" type="osx:type" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="directives">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element ref="osx:include"/>
      <xs:element ref="osx:xiso_include"/>
      <xs:element ref="osx:ximpl_include"/>
      <xs:element ref="osx:namespace"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="imports">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="resolve" type="osx:resolve"/>
      <xs:element name="type" type="osx:type"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="resolve">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="name" type="xs:string" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:complexType name="type">
    <xs:annotation> @name is for Schema type name. </xs:annotation>
    <xs:sequence>
      <xs:group ref="osx:primitive"/>
      <xs:element name="array" type="osx:builtin_array" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required"/>
  </xs:complexType>

  <xs:complexType name="builtin_array">
    <xs:sequence>
      <xs:group ref="osx:primitive"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required"/>
  </xs:complexType>

  <xs:group name="primitive">
    <xs:all>
      <xs:element name="value_type" type="xs:token" minOccurs="0"/>
      <xs:element name="typedef_of" type="xs:token" minOccurs="0"/>
      <xs:element name="leaf" type="xs:token" minOccurs="0"/>
    </xs:all>
  </xs:group>

</xs:schema>
