<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:annotation>
        <xs:documentation>Standard part of any Resource Profile</xs:documentation>
    </xs:annotation>
    <xs:element name="RESOURCE_PROFILE">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="HEADER" type="HEADERType"/>
                <xs:element name="BODY" type="BODYType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="HEADERType">
        <xs:all>
            <xs:element name="RESOURCE_IDENTIFIER" type="RESOURCE_IDENTIFIERType"/>
            <xs:element name="RESOURCE_TYPE" type="RESOURCE_TYPEType"/>
            <xs:element name="RESOURCE_KIND" type="RESOURCE_KINDType"/>
            <xs:element name="RESOURCE_URI" type="RESOURCE_URIType"/>
            <xs:element name="DATE_OF_CREATION" type="DATEType"/>
        </xs:all>
    </xs:complexType>
    <xs:complexType name="BODYType">
        <xs:sequence>
            <xs:element name="CONFIGURATION" type="CONFIGURATIONType"/>
            <xs:element name="STATUS" type="STATUSType"/>
            <xs:element ref="SECURITY_PARAMETERS"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="RESOURCE_IDENTIFIERType">
        <xs:attribute name="value" type="xs:string" use="required"/>
    </xs:complexType>
    <xs:complexType name="RESOURCE_TYPEType">
        <xs:attribute name="value" use="required">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="OAIPublisherConfigurationDSResourceType"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="RESOURCE_KINDType">
        <xs:attribute name="value" use="required">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="OAIPublisherConfigurationDSResources"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="RESOURCE_URIType">
        <xs:attribute name="value" type="xs:string" use="required"/>
    </xs:complexType>
    <xs:complexType name="DATEType">
        <xs:attribute name="value" type="xs:dateTime" use="required"/>
    </xs:complexType>
    <xs:annotation>
        <xs:documentation>Customisable part of any Resource Profile</xs:documentation>
    </xs:annotation>
    <xs:complexType name="CONFIGURATIONType">
        <xs:sequence>
            <xs:element name="IDSCHEME" type="xs:string"/>
            <xs:element name="IDNAMESPACE" type="xs:string"/>
            <xs:element name="CURRENTDB" type="xs:string"/>
            <xs:element name="OAISETS" type="OAISETSType"/>
            <xs:element name="METADATAFORMATS" type="METADATAFORMATSType"/>
            <xs:element name="INDICES" type="INDICESType"/>
            <xs:element name="ENRICHMENT" type="ENRICHMENTType" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="ENRICHMENTType">
        <xs:annotation>
            <xs:documentation>ENRICHMENT: xpaths to identify when a record has
                been enriched
                and must thus be inserted into a special
                "setSpec_enriched"</xs:documentation>
        </xs:annotation>
        <xs:sequence>
        <xs:element name="XPATH" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
                <xs:attribute name="interpretation" type="xs:string" use="required"/>
                <xs:attribute name="layout" type="xs:string" use="required"/>
                <xs:attribute name="name" type="xs:string" use="required"/>
                <xs:attribute name="path" type="xs:string" use="required"/>
            </xs:complexType>
        </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="OAISETSType">
        <xs:sequence>
            <xs:element name="OAISET" type="OAISETType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="OAISETType">
        <xs:annotation>
            <xs:documentation>
                Definition of the OAI sets to export.
                <ul>
                    <li>element spec: the setSpec.</li>
                    <li>element name: the name of the set</li>
                    <li>element description: description of the set</li>
                    <li>element query: records in this set are results of this query</li>
                    <li>attribute enabled: is the OAI set to export? Default is true</li>
                </ul>
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="spec" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="query" type="xs:string" minOccurs="1" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="enabled" type="xs:boolean" use="optional"/>
    </xs:complexType>
    <xs:complexType name="METADATAFORMATSType">
        <xs:sequence>
            <xs:element name="METADATAFORMAT" type="METADATAFORMATType" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="METADATAFORMATType">
        <xs:annotation>
            <xs:documentation>
                <ul>
                    <li>@exportable: true if we want to export
                        the metadata format via
                        OAI-PMH. Default is false.</li>
                    <li>@metadataPrefix: metadata prefix to be used for
                        OAI-PMH call.
                        E.g.,
                        oai_dc</li>
                    <li>NAMESPACE: target metadata format
                        namespace (xmlns). E.g.,
                        http://www.openarchives.org/OAI/2.0/oai_dc/</li>
                    <li/>
                    <li>SCHEMA: URL to the XML Schema. E.g.,
                        http://www.openarchives.org/OAI/2.0/oai_dc.xsd</li>
                    <li>SOURCE_METADATA_FORMAT/@name: metadata format of the mdstores
                        to be used as sources</li>
                    <li>SOURCE_METADATA_FORMAT/@interpretation: interpretation of the
                        mdstores to be used as sources</li>
                    <li>SOURCE_METADATA_FORMAT/@layout: layout of the mdstores to be
                        used as sources</li>
                    <li>TRANSFORMATION_RULE: identifier of the transformation to apply
                        to source records and transform them into the target
                        format</li>
                    <li>BASE_QUERY: base query to apply to filter records to export</li>
                </ul>
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="NAMESPACE" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="SCHEMA" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="SOURCE_METADATA_FORMAT">
                <xs:complexType>
                    <xs:attribute name="name" type="xs:string" use="required"/>
                    <xs:attribute name="interpretation" type="xs:string" use="required"/>
                    <xs:attribute name="layout" type="xs:string" use="required"/>
                </xs:complexType>
            </xs:element>
            <xs:element name="TRANSFORMATION_RULE" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="BASE_QUERY" type="xs:string" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="exportable" type="xs:boolean" use="optional"/>
        <xs:attribute name="metadataPrefix" type="xs:string" use="required"/>
    </xs:complexType>
    <xs:complexType name="INDICESType">
        <xs:annotation>
            <xs:documentation>
                One INDEX element represents one index to be created in the
                PublisherStore.
                When defining one index, you need to specify where to
                find the value to
                be stored in that indexed field for each source
                metadata formats.
                <ul>
                    <li>SOURCE: information to identify one source metadata format</li>
                    <li>SOURCE/@path: xpath where to find the value to be used in the
                        indexed field.</li>
                </ul>
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="INDEX" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="SOURCE" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                                <xs:attribute name="interpretation" type="xs:string" use="required"/>
                                <xs:attribute name="layout" type="xs:string" use="required"/>
                                <xs:attribute name="name" type="xs:string" use="required"/>
                                <xs:attribute name="path" type="xs:string" use="required"/>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                    <xs:attribute name="name" type="xs:string" use="required"/>
                    <xs:attribute name="repeatable" type="xs:boolean" use="required"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="STATUSType">
        <xs:all>
            <xs:element name="LAST_UPDATE" type="DATEType"/>
        </xs:all>
    </xs:complexType>
    <xs:element name="SECURITY_PARAMETERS" type="xs:string"/>
</xs:schema>
