<?xml version="1.0" encoding="UTF-8"?>
<xs:schema  xmlns:xs='http://www.w3.org/2001/XMLSchema'
             elementFormDefault="qualified"
             targetNamespace="http://www.w3.org/2001/XMLSchema">

  <xs:element name="schema" type="schema_type"/>

  <xs:simpleType name="unbounded_value">
    <xs:restriction base="xs:string">
      <xs:enumeration value="unbounded"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="occurence_type">
    <xs:union memberTypes="unbounded_value xs:nonNegativeInteger"/>
  </xs:simpleType>

  <xs:complexType name="attribute_type">
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="type" type="xs:string"/>
  </xs:complexType>

  <xs:complexType name="schema_type">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="element" type="element_type"/>
      <xs:element name="complexType" type="complexType_type"/>
    </xs:choice>
    <xs:attribute name="targetNamespace" type="xs:string"/>
  </xs:complexType>

  <xs:complexType name="element_type">
    <xs:sequence>
      <xs:element name="complexType" type="complexType_type" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="type" type="xs:string"/>
  </xs:complexType>

  <xs:complexType name="local_element_type">
    <xs:sequence>
      <xs:element name="complexType" type="complexType_type" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="type" type="xs:string"/>
    <xs:attribute name="ref" type="xs:string"/>
    <xs:attribute name="minOccurs" type="xs:integer"/>
    <xs:attribute name="maxOccurs" type="occurence_type"/>
  </xs:complexType>

  <xs:complexType name="complexType_type">
    <xs:choice minOccurs="1" maxOccurs="unbounded">
      <xs:element name="choice" type="choice_type"/>
      <xs:element name="sequence" type="sequence_type"/>
      <xs:element name="element" type="local_element_type"/>
      <xs:element name="attribute" type="attribute_type" minOccurs="0" maxOccurs="unbounded"/>
    </xs:choice>
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="type" type="xs:string"/>
  </xs:complexType>

  <xs:complexType name="sequence_type">
    <xs:choice>
      <xs:element name="element" type="local_element_type" minOccurs="1" maxOccurs="unbounded"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="choice_type">
    <xs:sequence>
      <xs:element name="element" type="local_element_type" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="minOccurs" type="xs:integer"/>
    <xs:attribute name="maxOccurs" type="occurence_type"/>
  </xs:complexType>

</xs:schema>
