<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
	xmlns:cdx="http://cdox.sf.net/schema/fileformat"
	targetNamespace="http://cdox.sf.net/schema/fileformat"
	elementFormDefault="qualified">

  <element name="cdox" type="cdx:cdoxtype"/>

  <!--
  The root element can contain one of the front elements (cdfront/cdbooklet) and
  a backside. Everything is optional, although a file without any cover does not
  make much sense.
  -->
  <complexType name="cdoxtype">
    <sequence>
      <!--
      Description and sub-tags are at the end of the schema.
      -->
      <element name="description" type="cdx:descriptiontype" minOccurs="0"/>
      <choice>
	<element name="cdfront" type="cdx:cdfronttype" minOccurs="0" maxOccurs="1"/>
	<element name="cdbooklet" type="cdx:cdbooklettype" minOccurs="0"
		 maxOccurs="1"/>
      </choice>
      <element name="cdback" type="cdx:cdbacktype" minOccurs="0"
	       maxOccurs="1"/>
	<!--	<element name="cdfront" type="cdx:cdfronttype" minOccurs="0" maxOccurs="1"/>
      <element name="cdbooklet" type="cdx:cdbooklettype" minOccurs="0"
	maxOccurs="1"/>
      <element name="cdback" type="cdx:cdbacktype" minOccurs="0"
	maxOccurs="1"/>-->
    </sequence>

    <!--
    The following should indicate the version of this spec. Current version
    is "1".
    -->
    <attribute name="version" use="required" type="string"/>
  </complexType>

  <!--
  The three types can contain a color attribute (RGB) and zero or more
  elements. The attribute freesides of the cdback type will leave the side
  borders free, if true (on the matter of the background image).
  -->
  <complexType name="cdfronttype">
    <sequence>
      <element name="element" type="cdx:elementtype" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
    <attribute name="color" use="optional" type="long"/>
    <attribute name="image" use="optional"/>
  </complexType>

  <complexType name="cdbacktype">
    <sequence>
      <element name="element" type="cdx:elementtype" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
    <attribute name="color" use="optional" type="long"/>
    <attribute name="image" use="optional"/>
    <attribute name="freesides" use="optional" type="boolean"/>
  </complexType>

  <complexType name="cdbooklettype">
    <sequence>
      <element name="element" type="cdx:elementtype" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
    <attribute name="color" use="optional" type="long"/>
    <attribute name="image" use="optional"/>
  </complexType>

  <!--
  The elementtype must contain the attributes specifying the position,
  size and type. They must also contain exactly one content
  element. The aspect attribute should be considered implied as true
  for text elements (should have only an effect on images).
  -->
  <complexType name="elementtype">
    <sequence>
      <element name="content" type="cdx:contenttype" minOccurs="1" maxOccurs="1"/>
    </sequence>
    <attribute name="positionx" use="required" type="unsignedShort"/>
    <attribute name="positiony" use="required" type="unsignedShort"/>
    <attribute name="sizex" use="required" type="unsignedShort"/>
    <attribute name="sizey" use="required" type="unsignedShort"/>
    <attribute name="type" use="required" type="string"/>
    <attribute name="rotate" use="optional" type="decimal"/>
    <attribute name="fliphoriz" use="required" type="boolean"/>
    <attribute name="flipvert" use="required" type="boolean"/>
    <attribute name="aspect" use="required" type="boolean"/>
    <attribute name="aspectx" use="required" type="decimal"/>
    <attribute name="aspecty" use="required" type="decimal"/>
  </complexType>

  <!--
  The contenttype must contain exactly one of the file or text
  elements. The text element can occur more than one time, each
  of them identifying a different styled part of the text element.
  -->
  <complexType name="contenttype">
    <choice>
      <element name="file" type="cdx:filetype" maxOccurs="1"/>
      <element name="text" type="cdx:texttype" maxOccurs="unbounded"/>
    </choice>
  </complexType>

  <!--
  The filetype contains a reference to an external file that should be
  loaded for the content.
  -->
  <complexType name="filetype">
    <attribute name="name" use="required"/>
  </complexType>

  <!--
  The texttype contains required attributes which uniquely identify
  the sequence of text such as font, textsize etc. The text in the text
  attribute must be Base64 encoded (on the matter of special chars like newlines
  etc.).
  -->
  <complexType name="texttype">
    <attribute name="font" use="required"/>
    <attribute name="text" use="required"/>
    <attribute name="height" use="required" type="unsignedByte"/>
    <attribute name="color" use="required" type="long"/>
    <attribute name="bold" use="required" type="boolean"/>
    <attribute name="italic" use="required" type="boolean"/>
    <attribute name="underline" use="required" type="boolean"/>
  </complexType>

  <!--
  Here should all other information about a particular CD go, like Artist,
  Tracks, textual description and so on. The type should currently be one of
  AudioData, VideoData or GenericData. If one wants to use another type, an
  appropriate plugin (implements Data) must be written that can read and write
  it.
  -->
  <complexType name="descriptiontype">
    <!--
    That's the choice for the type of CD.
    -->
    <choice>
      <element name="audiocd" type="cdx:audiotype" minOccurs="1" maxOccurs="1"/>
      <element name="videocd" type="cdx:videotype" minOccurs="1" maxOccurs="1"/>
      <element name="genericcd" type="cdx:generictype" minOccurs="1" maxOccurs="1"/>
    </choice>
    <attribute name="type" type="string" use="required"/>
  </complexType>

  <!--
  The first one is for audio CDs.
  -->
  <complexType name="audiotype">
    <sequence>
      <element name="artist" type="string" minOccurs="1" maxOccurs="1"/>
      <element name="title" type="string" minOccurs="1" maxOccurs="1"/>
      <element name="subtitle" type="string" minOccurs="0" maxOccurs="1"/>
      <element name="description" type="string" minOccurs="0" maxOccurs="1"/>
      <element name="tracks" type="cdx:trackstype" minOccurs="0" maxOccurs="1"/>
    </sequence>
  </complexType>

  <!--
  For video CDs.
  -->
  <complexType name="videotype">
    <sequence>
      <element name="title" type="string" minOccurs="1" maxOccurs="1"/>
      <element name="subtitle" type="string" minOccurs="0" maxOccurs="1"/>
      <element name="format" type="string" minOccurs="0" maxOccurs="1"/>
      <element name="description" type="string" minOccurs="0" maxOccurs="1"/>
      <element name="length" type="duration" minOccurs="0" maxOccurs="1"/>
    </sequence>
  </complexType>

  <!--
  For other content. The string elements must have Base64 encoded content.
  -->
  <complexType name="generictype">
    <sequence>
      <element name="title" type="string" minOccurs="1" maxOccurs="1"/>
      <element name="string" type="string" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
  </complexType>

  <!--
  The track type with track subelements.
  -->
  <complexType name="trackstype">
    <sequence>
      <element name="track" minOccurs="0" maxOccurs="unbounded">
	<complexType>
	  <!--
	  Should be the displayable tracknumber (eg. 01), therefore a string. The
	  track title should be, well, the track title.
	  -->
	  <attribute name="number" use="required" type="string"/>
	  <attribute name="title" use="required" type="string"/>
	  <!--
	  Well, I should really restrict the duration type.
	  -->
	  <attribute name="length" use="optional" type="duration"/>
	</complexType>
      </element>
    </sequence>
  </complexType>

</schema>
