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

    The contents of this file are subject to the license and copyright
    detailed in the LICENSE and NOTICE files at the root of the source
    tree and available online at

    http://www.dspace.org/license/

	Developed by DSpace @ Lyncode <dspace@lyncode.com>
 -->
<Configuration indented="false" maxListIdentifiersSize="100" maxListRecordsSize="100"
               maxListSetsSize="100" stylesheet="static/style.xsl"
               xmlns="http://www.lyncode.com/XOAIConfiguration">

    <Contexts>
        <Context baseurl="request" name="Default Context">
            <!-- Restrict access to hidden items by default -->
            <Filter ref="defaultFilter"/>

            <Format ref="oaidc"/>
            <Format ref="mets"/>
            <Format ref="xoai"/>
            <Format ref="didl"/>
            <Format ref="dim"/>
            <Format ref="ore"/>
            <Format ref="rdf"/>
            <Format ref="etdms"/>
            <Format ref="mods"/>
            <Format ref="qdc"/>
            <Format ref="marc"/>
            <Format ref="uketd_dc"/>
            <!--<Format ref="junii2" />-->
            <Description>
                This is the default context of the DSpace OAI-PMH data provider.
            </Description>
        </Context>

        <!--
            Driver Guidelines:

            - http://www.driver-support.eu/documents/DRIVER_Guidelines_v2_Final_2008-11-13.pdf

            Page 57 - 58
         -->
        <Context baseurl="driver" name="Driver Context">
            <!-- Date format, field prefixes, etc are ensured by the transformer -->
            <Transformer ref="driverTransformer"/>
            <!-- The driver filter -->
            <Filter ref="driverFilter"/>
            <!-- Just an alias, in fact it returns all items within the driver context -->
            <Set ref="driverSet"/>
            <!-- Metadata Formats -->
            <Format ref="oaidc"/>
            <Format ref="mets"/>
            <Format ref="didl"/>
            <Description>
                This context complies with Driver rules.
            </Description>
        </Context>

        <!--
            OpenAIRE Guidelines 3.0:

            - https://guidelines.openaire.eu/

            There is a limitation over the embargoedEndDate parameter:

            - Predefined DSpace fields don't allow to set this up with a default.
         -->
        <Context baseurl="openaire" name="OpenAIRE Context">
            <!-- Date format, field prefixes, etc are ensured by the transformer -->
            <Transformer ref="openaireTransformer"/>
            <!-- OpenAIRE filter -->
            <Filter ref="openAireFilter"/>
            <!-- Just an alias, in fact it returns all items within the driver context -->
            <Set ref="openaireSet"/>
            <!-- Metadata Formats -->
            <Format ref="oaidc"/>
            <Format ref="mets"/>
            <Description>
                This contexts complies with OpenAIRE Guidelines for Literature Repositories v3.0.
            </Description>
        </Context>
    </Contexts>


    <Formats>
        <Format id="oaidc">
            <Prefix>oai_dc</Prefix>
            <XSLT>metadataFormats/oai_dc.xsl</XSLT>
            <Namespace>http://www.openarchives.org/OAI/2.0/oai_dc/</Namespace>
            <SchemaLocation>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</SchemaLocation>
        </Format>
        <Format id="mets">
            <Prefix>mets</Prefix>
            <XSLT>metadataFormats/mets.xsl</XSLT>
            <Namespace>http://www.loc.gov/METS/</Namespace>
            <SchemaLocation>http://www.loc.gov/standards/mets/mets.xsd</SchemaLocation>
        </Format>
        <!-- Shows the XOAI internal generated XML -->
        <Format id="xoai">
            <Prefix>xoai</Prefix>
            <XSLT>metadataFormats/xoai.xsl</XSLT>
            <Namespace>http://www.lyncode.com/xoai</Namespace>
            <SchemaLocation>http://www.lyncode.com/schemas/xoai.xsd</SchemaLocation>
        </Format>
        <Format id="didl">
            <Prefix>didl</Prefix>
            <XSLT>metadataFormats/didl.xsl</XSLT>
            <Namespace>urn:mpeg:mpeg21:2002:02-DIDL-NS</Namespace>
            <SchemaLocation>http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-21_schema_files/did/didl.xsd
            </SchemaLocation>
        </Format>
        <Format id="dim">
            <Prefix>dim</Prefix>
            <XSLT>metadataFormats/dim.xsl</XSLT>
            <Namespace>http://www.dspace.org/xmlns/dspace/dim</Namespace>
            <SchemaLocation>http://www.dspace.org/schema/dim.xsd</SchemaLocation>
        </Format>
        <Format id="ore">
            <Prefix>ore</Prefix>
            <XSLT>metadataFormats/ore.xsl</XSLT>
            <Namespace>http://www.w3.org/2005/Atom</Namespace>
            <SchemaLocation>http://tweety.lanl.gov/public/schemas/2008-06/atom-tron.sch</SchemaLocation>
        </Format>
        <Format id="rdf">
            <Prefix>rdf</Prefix>
            <XSLT>metadataFormats/rdf.xsl</XSLT>
            <Namespace>http://www.openarchives.org/OAI/2.0/rdf/</Namespace>
            <SchemaLocation>http://www.openarchives.org/OAI/2.0/rdf.xsd</SchemaLocation>
        </Format>
        <Format id="etdms">
            <Prefix>etdms</Prefix>
            <XSLT>metadataFormats/etdms.xsl</XSLT>
            <Namespace>http://www.ndltd.org/standards/metadata/etdms/1.0/</Namespace>
            <SchemaLocation>http://www.ndltd.org/standards/metadata/etdms/1.0/etdms.xsd</SchemaLocation>
        </Format>
        <Format id="mods">
            <Prefix>mods</Prefix>
            <XSLT>metadataFormats/mods.xsl</XSLT>
            <Namespace>http://www.loc.gov/mods/v3</Namespace>
            <SchemaLocation>http://www.loc.gov/standards/mods/v3/mods-3-1.xsd</SchemaLocation>
        </Format>
        <Format id="qdc">
            <Prefix>qdc</Prefix>
            <XSLT>metadataFormats/qdc.xsl</XSLT>
            <Namespace>http://purl.org/dc/terms/</Namespace>
            <SchemaLocation>http://dublincore.org/schemas/xmls/qdc/2006/01/06/dcterms.xsd</SchemaLocation>
        </Format>
        <Format id="marc">
            <Prefix>marc</Prefix>
            <XSLT>metadataFormats/marc.xsl</XSLT>
            <Namespace>http://www.loc.gov/MARC21/slim</Namespace>
            <SchemaLocation>http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</SchemaLocation>
        </Format>
        <Format id="uketd_dc">
            <Prefix>uketd_dc</Prefix>
            <XSLT>metadataFormats/uketd_dc.xsl</XSLT>
            <Namespace>http://naca.central.cranfield.ac.uk/ethos-oai/2.0/</Namespace>
            <SchemaLocation>http://naca.central.cranfield.ac.uk/ethos-oai/2.0/uketd_dc.xsd</SchemaLocation>
            <Filter ref="uketdDcFilter"/>
        </Format>
        <Format id="junii2">
            <Prefix>junii2</Prefix>
            <XSLT>metadataFormats/junii2.xsl</XSLT>
            <Namespace>http://irdb.nii.ac.jp/oai</Namespace>
            <SchemaLocation>http://irdb.nii.ac.jp/oai/junii2-3-1.xsd</SchemaLocation>
        </Format>
    </Formats>

    <Transformers>
        <Transformer id="driverTransformer">
            <XSLT>transformers/driver.xsl</XSLT>
        </Transformer>
        <Transformer id="openaireTransformer">
            <XSLT>transformers/openaire.xsl</XSLT>
        </Transformer>
    </Transformers>


    <Filters>
        <!-- DRIVER filter for records returned by OAI-PMH.
             By default, return an Item record:
               * If a Title & Author field both exist
               * AND a valid DRIVER Document Type exists
               * AND Item is either publicly accessible OR Withdrawn (for tombstones)
               * AND Driver "open access" condition is specified
             This filter is only used in the DRIVER context ([oai]/driver)
        -->
        <Filter id="driverFilter">
            <Definition>
                <And>
                    <LeftCondition>
                        <And>
                            <LeftCondition>
                                <Custom ref="titleExistsCondition"/>
                            </LeftCondition>
                            <RightCondition>
                                <Custom ref="authorExistsCondition"/>
                            </RightCondition>
                        </And>
                    </LeftCondition>
                    <RightCondition>
                        <And>
                            <LeftCondition>
                                <Custom ref="driverDocumentTypeCondition"/>
                            </LeftCondition>
                            <RightCondition>
                                <And>
                                    <LeftCondition>
                                        <Or>
                                            <LeftCondition>
                                                <Custom ref="itemAccessCondition"/>
                                            </LeftCondition>
                                            <RightCondition>
                                                <Custom ref="itemWithdrawnCondition"/>
                                            </RightCondition>
                                        </Or>
                                    </LeftCondition>
                                    <RightCondition>
                                        <Custom ref="driverAccessCondition"/>
                                    </RightCondition>
                                </And>
                            </RightCondition>
                        </And>
                    </RightCondition>
                </And>
            </Definition>
        </Filter>

        <!-- OpenAIRE filter for records returned by OAI-PMH.
             By default, return an Item record:
               * If a Title & Author field both exist
               * AND a valid DRIVER Document Type exists
               * AND Item is either publicly accessible OR Withdrawn (for tombstones)
               * AND the OpenAIRE "dc.relation" is specified
             This filter is only used in the OpenAIRE context ([oai]/openaire).
        -->
        <Filter id="openAireFilter">
            <Definition>
                <And>
                    <LeftCondition>
                        <And>
                            <LeftCondition>
                                <And>
                                    <LeftCondition>
                                        <Custom ref="titleExistsCondition"/>
                                    </LeftCondition>
                                    <RightCondition>
                                        <Custom ref="authorExistsCondition"/>
                                    </RightCondition>
                                </And>
                            </LeftCondition>
                            <RightCondition>
                                <Custom ref="driverDocumentTypeCondition"/>
                            </RightCondition>
                        </And>
                    </LeftCondition>
                    <RightCondition>
                        <Or>
                            <LeftCondition>
                                <And>
                                    <LeftCondition>
                                        <Or>
                                            <LeftCondition>
                                                <Custom ref="itemAccessCondition"/>
                                            </LeftCondition>
                                            <RightCondition>
                                                <Custom ref="itemWithdrawnCondition"/>
                                            </RightCondition>
                                        </Or>
                                    </LeftCondition>
                                    <RightCondition>
                                        <Custom ref="driverAccessCondition"/>
                                    </RightCondition>
                                </And>
                            </LeftCondition>
                            <RightCondition>
                                <Custom ref="openaireRelationCondition"/>
                            </RightCondition>
                        </Or>
                    </RightCondition>
                </And>
            </Definition>
        </Filter>

        <!-- UKETD Filter for records returned by OAI-PMH.
             By default, return an Item record:
                * If it is a "thesis"

             This filter is appended to any existing filter
             when "metadataPrefix=uketd_dc" is specified.
        -->
        <Filter id="uketdDcFilter">
            <Definition>
                <Custom ref="thesisDocumentTypeCondition"/>
            </Definition>
        </Filter>

        <!-- Default filter for records returned by OAI-PMH. 
             By default, return an Item record:
                * If it is publicly accessible
                * OR it has been withdrawn (in order to display a tombstone record).
             This filter is used by the default context ([oai]/request).
        -->
        <Filter id="defaultFilter">
            <Definition>
                <Or>
                    <LeftCondition>
                        <Custom ref="itemAccessCondition"/>
                    </LeftCondition>
                    <RightCondition>
                        <Custom ref="itemWithdrawnCondition"/>
                    </RightCondition>
                </Or>
            </Definition>
        </Filter>

        <!-- This condition determines if an Item has a "dc.type" field
             which contains "Thesis". -->
        <CustomCondition id="thesisDocumentTypeCondition">
            <Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
            <Configuration>
                <string name="field">dc.type</string>
                <string name="operator">contains</string>
                <string name="value">Thesis</string>
            </Configuration>
        </CustomCondition>

        <!-- This condition determines if an Item has a "dc.contributor.author" -->
        <CustomCondition id="authorExistsCondition">
            <Class>org.dspace.xoai.filter.DSpaceMetadataExistsFilter</Class>
            <Configuration>
                <string name="field">dc.contributor.author</string>
            </Configuration>
        </CustomCondition>

        <!-- This condition determines if an Item has a "dc.title" -->
        <CustomCondition id="titleExistsCondition">
            <Class>org.dspace.xoai.filter.DSpaceMetadataExistsFilter</Class>
            <Configuration>
                <string name="field">dc.title</string>
            </Configuration>
        </CustomCondition>

        <!-- This condition determines if an Item has a "dc.type" field
             specifying one of the valid DRIVER document types. -->
        <CustomCondition id="driverDocumentTypeCondition">
            <Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
            <Configuration>
                <string name="field">dc.type</string>
                <string name="operator">ends_with</string>
                <list name="values">
                    <string>article</string>
                    <string>bachelorThesis</string>
                    <string>masterThesis</string>
                    <string>doctoralThesis</string>
                    <string>book</string>
                    <string>bookPart</string>
                    <string>review</string>
                    <string>conferenceObject</string>
                    <string>lecture</string>
                    <string>workingPaper</string>
                    <string>preprint</string>
                    <string>report</string>
                    <string>annotation</string>
                    <string>contributionToPeriodical</string>
                    <string>patent</string>
                    <string>dataset</string>
                    <string>other</string>
                </list>
            </Configuration>
        </CustomCondition>

        <!-- This condition determines if an Item has a "dc.rights" field
             specifying "open access", which is required for DRIVER
             OR "openAccess", which is required by OpenAIRE. -->
        <CustomCondition id="driverAccessCondition">
            <Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
            <Configuration>
                <string name="field">dc.rights</string>
                <string name="operator">contains</string>
                <list name="values">
                    <string>openAccess</string>
                </list>
            </Configuration>
        </CustomCondition>

        <!-- This condition determines if an Item is publicly accessible. -->
        <CustomCondition id="itemAccessCondition">
            <Class>org.dspace.xoai.filter.DSpaceAuthorizationFilter</Class>
        </CustomCondition>

        <!-- This condition determines if an Item is withdrawn. This condition
             ensures a basic "tombstone" record is shown for withdrawn items,
             as recommended by OAI-PMH spec. This "tombstone" doesn't display
             any metadata or content files.  -->
        <CustomCondition id="itemWithdrawnCondition">
            <Class>org.dspace.xoai.filter.DSpaceWithdrawnFilter</Class>
        </CustomCondition>

        <!-- This condition determines if an Item has a "dc.relation" field
             which specifies the openAIRE project ID. -->
        <CustomCondition id="openaireRelationCondition">
            <Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
            <Configuration>
                <string name="field">dc.relation</string>
                <string name="operator">starts_with</string>
                <string name="value">info:eu-repo/grantAgreement/</string>
            </Configuration>
        </CustomCondition>
    </Filters>

    <Sets>
        <Set id="driverSet">
            <Spec>driver</Spec>
            <Name>Open Access DRIVERset</Name>
            <!-- Just an alias -->
        </Set>
        <Set id="openaireSet">
            <Spec>openaire</Spec>
            <Name>OpenAIRE</Name>
            <!-- Just an alias -->
        </Set>
    </Sets>
</Configuration>
