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

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

  <xs:element name="section">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="sect:title"/>
        <xs:choice>
          <xs:element maxOccurs="unbounded" ref="sect:block-elements"/>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" 
                        ref="sect:block-elements"/>
            <xs:element maxOccurs="unbounded" ref="sect:section"/>
          </xs:sequence>
        </xs:choice>
      </xs:sequence>
      <xs:attributeGroup ref="sect:common-attributes"/>
    </xs:complexType>
  </xs:element>

  <xs:attributeGroup name="common-attributes">
    <xs:attribute ref="xml:lang"/>
  </xs:attributeGroup>

  <xs:element name="title">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="sect:inline-content">
          <xs:attributeGroup ref="sect:common-attributes"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="inline-content" mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element ref="sect:bold"/>
      <xs:element ref="sect:italic"/>
      <xs:element ref="sect:literal"/>
      <xs:element ref="sect:break"/>
      <xs:element ref="sect:image"/>
    </xs:choice>
  </xs:complexType>

  <xs:element name="block-elements" abstract="true"/>

  <xs:element name="paragraph" substitutionGroup="sect:block-elements">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="sect:inline-content">
          <xs:attributeGroup ref="sect:common-attributes"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="bold">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="sect:inline-content">
          <xs:attributeGroup ref="sect:common-attributes"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="italic">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="sect:inline-content">
          <xs:attributeGroup ref="sect:common-attributes"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="literal">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="sect:inline-content">
          <xs:attributeGroup ref="sect:common-attributes"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="break">
    <xs:complexType>
      <xs:attributeGroup ref="sect:common-attributes"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="image">
    <xs:complexType>
      <xs:attributeGroup ref="sect:common-attributes"/>
      <xs:attribute name="source" use="required" type="xs:anyURI"/>
      <xs:attribute name="width" type="xs:positiveInteger"/>
      <xs:attribute name="height" type="xs:positiveInteger"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="table" substitutionGroup="sect:block-elements">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="sect:tableHeader"/>
        <xs:element maxOccurs="unbounded" ref="sect:tableRow"/>
      </xs:sequence>
      <xs:attributeGroup ref="sect:common-attributes"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="tableHeader">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="sect:tableCell"/>
      </xs:sequence>
      <xs:attributeGroup ref="sect:common-attributes"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="tableRow">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="sect:tableCell"/>
      </xs:sequence>
      <xs:attributeGroup ref="sect:common-attributes"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="tableCell">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="sect:block-elements"/>
      </xs:sequence>
      <xs:attributeGroup ref="sect:common-attributes"/>
      <xs:attribute name="columns" type="xs:positiveInteger" default="1"/>
    </xs:complexType>
  </xs:element>

</xs:schema>
