<?xml version="1.0" encoding="utf-8"?>

<schema targetNamespace="http://www.cs.uga.edu/~boanerg/Bib"
        xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:b="http://www.cs.uga.edu/~boanerg/Bib"
        elementFormDefault="qualified">

  <annotation>
    <documentation xml:lang="en">
       Bib schema for authors and books.
    </documentation>
  </annotation>

  <element name="bib">

    <complexType name="bibType">
      <sequence>
        <element name="author" type="b:authorType" maxOccurs="unbounded"/>
        <element name="book" type="b:bookType" maxOccurs="unbounded">
          <keyref name="dummy2" refer="b:authorKey">
            <selector xpath="b:book"/>
            <field xpath="@author"/>
          </keyref>
        </element>
      </sequence>
    </complexType>

    <key name="authorKey">
      <selector xpath="b:author"/>
      <field xpath="@id"/>
    </key>

    <unique name="dummy1">
      <selector xpath="b:book/b:isbn"/>
      <field xpath="."/>
    </unique>

  </element>

  <complexType name="authorType">
    <sequence>
      <element name="firstname" type="string"/>
      <element name="lastname"  type="string"/>
    </sequence>
    <attribute name="id" type="NMTOKEN" use="required"/>
  </complexType>

  <complexType name="bookType">
    <sequence>
      <element name="title" type="string"/>
      <element name="isbn"  type="string"/>
      <element name="price">
        <simpleType>
        <restriction base="decimal">
          <minInclusive value="0.0"/>
          <maxExclusive value="500.0"/>
        </restriction>
        </simpleType>
      </element>
    </sequence>
    <attribute name="author" type="NMTOKEN" use="required"/>
  </complexType>


</schema>
