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

<xsd:schema xmlns="http://symfony.com/schema/dic/doctrine"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://symfony.com/schema/dic/doctrine"
    elementFormDefault="qualified">

    <xsd:element name="config">
        <xsd:complexType>
            <xsd:all>
                <xsd:element name="dbal" type="dbal" minOccurs="0" maxOccurs="1" />
                <xsd:element name="orm" type="orm" minOccurs="0" maxOccurs="1" />
            </xsd:all>
        </xsd:complexType>
    </xsd:element>

    <xsd:attributeGroup name="connection-config">
        <xsd:attribute name="driver" type="xsd:string" />
        <xsd:attribute name="driver-class" type="xsd:string" />
        <xsd:attribute name="wrapper-class" type="xsd:string" />
        <xsd:attribute name="platform-service" type="xsd:string" />
        <xsd:attribute name="logging" type="xsd:string" default="false" />
        <xsd:attribute name="profiling" type="xsd:string" default="false" />
        <xsd:attributeGroup ref="driver-config" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="driver-config">
        <xsd:attribute name="dbname" type="xsd:string" />
        <xsd:attribute name="host" type="xsd:string" />
        <xsd:attribute name="port" type="xsd:integer" />
        <xsd:attribute name="user" type="xsd:string" />
        <xsd:attribute name="password" type="xsd:string" />
        <xsd:attribute name="path" type="xsd:string" />
        <xsd:attribute name="unix-socket" type="xsd:string" />
        <xsd:attribute name="memory" type="xsd:boolean" />
        <xsd:attribute name="charset" type="xsd:string" />
        <xsd:attribute name="persistent" type="xsd:boolean" />
        <xsd:attribute name="protocol" type="xsd:string" />
        <xsd:attribute name="service" type="xsd:boolean" />
        <xsd:attribute name="session-mode" type="xsd:string" />
        <xsd:attribute name="pooled" type="xsd:boolean" />
        <xsd:attribute name="multiple-active-result-sets" type="xsd:boolean" />
    </xsd:attributeGroup>

    <xsd:complexType name="dbal">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="connection" type="connection" />
            <xsd:element name="type" type="type" />
            <xsd:element name="option" type="option" />
            <xsd:element name="mapping-type" type="mapping-type" />
            <xsd:element name="slave" type="slave" />
        </xsd:choice>

        <xsd:attribute name="default-connection" type="xsd:string" />
        <xsd:attributeGroup ref="connection-config" />
    </xsd:complexType>

    <xsd:complexType name="option">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="key" type="xsd:string" use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="mapping-type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="connection">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="option" type="option" />
            <xsd:element name="mapping-type" type="mapping-type" />
            <xsd:element name="slave" type="slave" />
        </xsd:choice>
        <xsd:attribute name="name" type="xsd:string" use="required" />
        <xsd:attributeGroup ref="connection-config" />
    </xsd:complexType>

    <xsd:complexType name="slave">
        <xsd:attribute name="name" type="xsd:string" use="required" />
        <xsd:attributeGroup ref="driver-config" />
    </xsd:complexType>

    <xsd:complexType name="mapping">
        <xsd:attribute name="name" type="xsd:string" use="required" />
        <xsd:attribute name="type" type="xsd:string" />
        <xsd:attribute name="dir" type="xsd:string" />
        <xsd:attribute name="alias" type="xsd:string" />
        <xsd:attribute name="prefix" type="xsd:string" />
        <xsd:attribute name="is-bundle" type="xsd:boolean" />
    </xsd:complexType>

    <xsd:complexType name="orm">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="entity-manager" type="entity_manager" />
            <xsd:element name="mapping" type="mapping" />
            <xsd:element name="metadata-cache-driver" type="metadata_cache_driver" minOccurs="0" maxOccurs="1" />
            <xsd:element name="dql" type="dql" minOccurs="0" maxOccurs="1" />
            <xsd:element name="filter" type="filter" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="resolve-target-entity" type="resolve_target_entity" minOccurs="0" maxOccurs="unbounded" />
        </xsd:choice>

        <xsd:attribute name="auto-mapping" type="xsd:string" />
        <xsd:attribute name="default-entity-manager" type="xsd:string" />
        <xsd:attribute name="default-connection" type="xsd:string" />

        <xsd:attribute name="proxy-dir" type="xsd:string" />
        <xsd:attribute name="proxy-namespace" type="xsd:string" />
        <xsd:attribute name="auto-generate-proxy-classes" type="xsd:string" default="false" />
        <xsd:attribute name="default-repository-class" type="xsd:string" />
        <xsd:attribute name="result-cache-driver" type="xsd:string" />
        <xsd:attribute name="metadata-cache-driver" type="xsd:string" />
        <xsd:attribute name="query-cache-driver" type="xsd:string" />
    </xsd:complexType>

    <xsd:complexType name="resolve_target_entity">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="interface" type="xsd:string" use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="metadata_cache_driver">
        <xsd:all>
            <xsd:element name="class" type="xsd:string" minOccurs="0" maxOccurs="1" />
            <xsd:element name="host" type="xsd:string" minOccurs="0" maxOccurs="1" />
            <xsd:element name="port" type="xsd:string" minOccurs="0" maxOccurs="1" />
            <xsd:element name="instance-class" type="xsd:string" minOccurs="0" maxOccurs="1" />
        </xsd:all>

        <xsd:attribute name="type" type="xsd:string" />
    </xsd:complexType>

    <xsd:complexType name="entity_manager">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="mapping" type="mapping" />
            <xsd:element name="metadata-cache-driver" type="metadata_cache_driver" minOccurs="0" maxOccurs="1" />
            <xsd:element name="dql" type="dql" minOccurs="0" maxOccurs="1" />
            <xsd:element name="hydrator" type="type" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="filter" type="filter" minOccurs="0" maxOccurs="unbounded" />
        </xsd:choice>

        <xsd:attribute name="auto-mapping" type="xsd:string" />
        <xsd:attribute name="connection" type="xsd:string" />
        <xsd:attribute name="name" type="xsd:string" />
        <xsd:attribute name="default-repository-class" type="xsd:string" />
        <xsd:attribute name="result-cache-driver" type="xsd:string" />
        <xsd:attribute name="metadata-cache-driver" type="xsd:string" />
        <xsd:attribute name="query-cache-driver" type="xsd:string" />
    </xsd:complexType>

    <xsd:complexType name="filter">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="name" type="xsd:string" use="required" />
                <xsd:attribute name="enabled" type="xsd:boolean" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="dql">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="string-function" type="dql_function" />
            <xsd:element name="numeric-function" type="dql_function" />
            <xsd:element name="datetime-function" type="dql_function" />
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="dql_function">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
</xsd:schema>
