<?xml version="1.0"?>
<!--  XML Schema schema for XInterface type definitions -->

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<!--
  <schema> must be root element of a XInterface type definition file
  each <interfaceType> child element defines one XInterface type
-->

<xsd:element name="schema">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="interfaceType" type="xitd" minOccurs="1" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

<!--
  an <interfaceType> element has one mandatory and one optional attribute
  and an arbitrary number of content declarations
-->
<xsd:complexType name="xitd">
  <xsd:attribute name="name" type="xsd:string"/>
  <xsd:attribute name="defaultNS" type="xsd:string" minOccurs="0"/>
  <xsd:sequence>
    <xsd:element ref="declaration" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>


<!-- base element for substitution group defining a content declaration -->
<xsd:element name="declaration" abstract="true"/>

<xsd:element name="attribute" type="attributeType" substitutionGroup="declaration"/>
<xsd:element name="element" type="elementType" substitutionGroup="declaration"/>
<xsd:element name="import" type="importType" substitutionGroup="declaration"/>

<!-- attribute declaration -->
<xsd:complexType name="attributeType">
  <xsd:attribute name="name" type="xsd:string"/>
  <xsd:attribute name="ns" type="xsd:string" minOccurs="0"/>
  <xsd:attribute name="type" type="xsd:string" minOccurs="0"/>
  <xsd:attribute name="initial" type="xsd:string" minOccurs="0"/>
  <xsd:attribute name="minOccurs" type="xsd:integer" minOccurs="0"/>
  <xsd:attribute name="maxOccurs" type="xsd:string" minOccurs="0"/>
</xsd:complexType>

<!-- element declaration -->
<!--
  we do not distinguish between flat and compound elements
  (<choice> not allowed for attributes)
  => schema incorrectly allows typed element with nested content
-->

<xsd:complexType name="elementType">
  <xsd:attribute name="name" type="xsd:string"/>
  <xsd:attribute name="ns" type="xsd:string" minOccurs="0"/>
  <xsd:attribute name="type" type="xsd:string" minOccurs="0"/>
  <xsd:attribute name="initial" type="xsd:string" minOccurs="0"/>
  <xsd:attribute name="minOccurs" type="xsd:integer" minOccurs="0"/>
  <xsd:attribute name="maxOccurs" type="xsd:string" minOccurs="0"/>
  <xsd:sequence>
    <xsd:element ref="declaration" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>

<!-- import declaration -->
<xsd:complexType name="importType">
  <xsd:attribute name="name" type="xsd:string"/>
  <xsd:attribute name="location" type="xsd:string" minOccurs="0"/>
</xsd:complexType>


</xsd:schema>

