<?xml version="1.0" encoding="UTF-8"?>
<!--

    The Castor JDO configuration file XML Schema

    Namespace: http://castor.exolab.org/JDO
    System:    http://castor.exolab.org/jdo-conf.xsd
    Public:    -//EXOLAB/Castor JDO Configuration Schema Version 1.0//EN

    Note: This schema is under evolution and subject to change.
 -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://castor.exolab.org/JDO"
  xmlns="http://castor.exolab.org/JDO"
  version="$$VERSION$$">

  <xsd:annotation>
    <xsd:documentation>
      XML Scheman for the main Castor JDO configuration file 
    </xsd:documentation>
  </xsd:annotation>

  <xsd:element name="jdo-conf">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="database" minOccurs="1" maxOccurs="unbounded" />
        <xsd:element ref="transaction-demarcation" minOccurs="0" maxOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="database">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:choice>
          <xsd:element ref="driver" />
          <xsd:element ref="data-source" />
          <xsd:element ref="jndi" />
        </xsd:choice>
        <xsd:element ref="mapping" minOccurs="1" maxOccurs="unbounded" />
      </xsd:sequence>
      <xsd:attribute name="name" type="xsd:ID" use="required"/>
      <xsd:attribute name="engine" type="xsd:string" use="optional" default="generic" />
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="mapping">
    <xsd:complexType>
      <xsd:attribute name="href" type="xsd:string" use="required" />
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="driver">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="url" type="xsd:string" use="required" />
      <xsd:attribute name="class-name" type="xsd:string" use="required" />
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="transaction-demarcation">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="transaction-manager" minOccurs="0" maxOccurs="1" />
      </xsd:sequence>
      <xsd:attribute name="mode" type="xsd:string" use="required"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="transaction-manager">
    <xsd:complexType>
      <xsd:sequence>
         <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="name" type="xsd:string" default="local" />
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="param">
    <xsd:complexType>
      <xsd:attribute name="name" type="xsd:string" use="required" />
      <xsd:attribute name="value" type="xsd:string" use="required" />
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="data-source">
    <xsd:complexType content="elemOnly" order="seq">
      <xsd:sequence>
        <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="class-name" type="xsd:string" use="required" />
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="jndi">
    <xsd:complexType>
       <xsd:attribute name="name" type="xsd:string" use="required" />
    </xsd:complexType>
  </xsd:element>

</xsd:schema>
