Skip to content

Commit

Permalink
#1149 Replace choosing XSLT-Mode with a static XSLT-Mode for <xsl:app…
Browse files Browse the repository at this point in the history
…ly-templates>.
  • Loading branch information
haogatyp committed Nov 9, 2023
1 parent 90af5d8 commit 5b44a67
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 151 deletions.
1 change: 0 additions & 1 deletion modules/oai/models/DefaultServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ private function handlingOfLists(array &$oaiRequest, $maxItems)
$oaiRequest['metadataPrefix'] = $metadataPrefix;
$oaiRequest['metadataPrefixMode'] = strtolower($metadataPrefix);
$this->proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
$this->proc->setParameter('', 'oai_metadataPrefixMode', strtolower($metadataPrefix));
$resumed = true;
} else {
// no resumptionToken is given
Expand Down
22 changes: 1 addition & 21 deletions modules/oai/views/scripts/index/oai-pmh.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
<xsl:param name="oai_until" />
<xsl:param name="oai_set" />
<xsl:param name="oai_metadataPrefix" />
<xsl:param name="oai_metadataPrefixMode" /><!-- strtolower version of oai_metadataPrefix TODO temp. hack -->
<xsl:param name="oai_resumptionToken" />
<xsl:param name="oai_identifier" />
<xsl:param name="oai_error_code" />
Expand Down Expand Up @@ -362,26 +361,7 @@
<xsl:choose>
<xsl:when test="$oai_verb!='ListIdentifiers' and @ServerState!='deleted'">
<metadata>
<xsl:choose>
<xsl:when test="$oai_metadataPrefixMode='xmetadissplus'">
<xsl:apply-templates select="." mode="xmetadissplus" />
</xsl:when>
<xsl:when test="$oai_metadataPrefixMode='epicur'">
<xsl:apply-templates select="." mode="epicur" />
</xsl:when>
<xsl:when test="$oai_metadataPrefixMode='oai_dc'">
<xsl:apply-templates select="." mode="oai_dc" />
</xsl:when>
<xsl:when test="$oai_metadataPrefixMode='oai_pp'">
<xsl:apply-templates select="." mode="oai_pp" />
</xsl:when>
<xsl:when test="$oai_metadataPrefixMode='copy_xml'">
<xsl:apply-templates select="." mode="copy_xml" />
</xsl:when>
<xsl:when test="$oai_metadataPrefixMode='marc21'">
<xsl:apply-templates select="." mode="marc21" />
</xsl:when>
</xsl:choose>
<xsl:apply-templates select="." mode="metadata_prefix_mode" />
</metadata>
</xsl:when>
</xsl:choose>
Expand Down
86 changes: 43 additions & 43 deletions modules/oai/views/scripts/index/prefixes/XMetaDissPlus.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,31 @@

<xsl:output method="xml" indent="yes" />

<xsl:template match="Opus_Document" mode="xmetadissplus">
<xsl:template match="Opus_Document" mode="metadata_prefix_mode">
<xMetaDiss:xMetaDiss
xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.d-nb.de/standards/xmetadissplus/ https://d-nb.info/standards/schema/xmetadissplus.xsd">

<!-- dc:title -->
<xsl:apply-templates select="TitleMain" mode="xmetadissplus" />
<xsl:apply-templates select="TitleSub" mode="xmetadissplus" />
<xsl:apply-templates select="TitleMain" mode="metadata_prefix_mode" />
<xsl:apply-templates select="TitleSub" mode="metadata_prefix_mode" />
<!-- dc:creator -->
<xsl:apply-templates select="PersonAuthor" mode="xmetadissplus" />
<xsl:apply-templates select="@CreatingCorporation" mode="xmetadissplus" />
<xsl:apply-templates select="@ContributingCorporation" mode="xmetadissplus" />
<xsl:apply-templates select="PersonAuthor" mode="metadata_prefix_mode" />
<xsl:apply-templates select="@CreatingCorporation" mode="metadata_prefix_mode" />
<xsl:apply-templates select="@ContributingCorporation" mode="metadata_prefix_mode" />
<!-- dc:subject -->
<xsl:apply-templates select="Collection[@RoleName='ddc' and @Visible=1]" mode="xmetadissplus" />
<xsl:apply-templates select="Subject[@Type='swd']" mode="xmetadissplus" />
<xsl:apply-templates select="Subject[@Type='uncontrolled']" mode="xmetadissplus" />
<xsl:apply-templates select="Collection[@RoleName='ddc' and @Visible=1]" mode="metadata_prefix_mode" />
<xsl:apply-templates select="Subject[@Type='swd']" mode="metadata_prefix_mode" />
<xsl:apply-templates select="Subject[@Type='uncontrolled']" mode="metadata_prefix_mode" />
<!-- dc:abstract -->
<xsl:apply-templates select="TitleAbstract" mode="xmetadissplus" />
<xsl:apply-templates select="TitleAbstract" mode="metadata_prefix_mode" />
<!-- dc:publisher -->
<xsl:apply-templates select="ThesisPublisher" mode="xmetadissplus" />
<xsl:apply-templates select="ThesisPublisher" mode="metadata_prefix_mode" />
<!-- dc:contributor -->
<xsl:apply-templates select="PersonAdvisor" mode="xmetadissplus" />
<xsl:apply-templates select="PersonReferee" mode="xmetadissplus" />
<xsl:apply-templates select="PersonEditor" mode="xmetadissplus" />
<xsl:apply-templates select="PersonAdvisor" mode="metadata_prefix_mode" />
<xsl:apply-templates select="PersonReferee" mode="metadata_prefix_mode" />
<xsl:apply-templates select="PersonEditor" mode="metadata_prefix_mode" />

<xsl:choose>
<xsl:when test="ThesisDateAccepted">
Expand Down Expand Up @@ -129,10 +129,10 @@
<!-- dc:identifier -->
<xsl:choose>
<xsl:when test="Identifier[@Type = 'urn']">
<xsl:apply-templates select="Identifier[@Type = 'urn']" mode="xmetadissplus" />
<xsl:apply-templates select="Identifier[@Type = 'urn']" mode="metadata_prefix_mode" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="Identifier[@Type = 'doi']" mode="xmetadissplus" />
<xsl:apply-templates select="Identifier[@Type = 'doi']" mode="metadata_prefix_mode" />
</xsl:otherwise>
</xsl:choose>

Expand All @@ -145,7 +145,7 @@
</xsl:for-each>

<!-- dc:source must appear after dc:identifier -->
<xsl:apply-templates select="TitleParent" mode="xmetadissplus" />
<xsl:apply-templates select="TitleParent" mode="metadata_prefix_mode" />

<!-- weird DNB constraint: dc:language must appear after dcterms:medium -->
<dc:language xsi:type="dcterms:ISO639-2">
Expand All @@ -158,11 +158,11 @@
<xsl:apply-templates select="Series" mode="xmetadissplusPeriodicalPart" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="Series" mode="xmetadissplus" />
<xsl:apply-templates select="Series" mode="metadata_prefix_mode" />
</xsl:otherwise>
</xsl:choose>

<xsl:apply-templates select="Licence" mode="xmetadissplus" />
<xsl:apply-templates select="Licence" mode="metadata_prefix_mode" />

<!-- thesis.degree only, if type doctoral or habilitation -->
<xsl:if test="@Type='bachelorthesis' or @Type='doctoralthesis' or @Type='habilitation' or @Type='masterthesis'
Expand Down Expand Up @@ -228,12 +228,12 @@
<ddb:fileNumber>
<xsl:value-of select="count(File)"/>
</ddb:fileNumber>
<xsl:apply-templates select="File" mode="xmetadissplus" />
<xsl:apply-templates select="File" mode="metadata_prefix_mode" />
<xsl:if test="File">
<xsl:apply-templates select="TransferUrl" mode="xmetadissplus" />
<xsl:apply-templates select="TransferUrl" mode="metadata_prefix_mode" />
</xsl:if>

<xsl:apply-templates select="Identifier[@Type = 'url']" mode="xmetadissplus" />
<xsl:apply-templates select="Identifier[@Type = 'url']" mode="metadata_prefix_mode" />

<ddb:identifier ddb:type="URL">
<xsl:value-of select="@frontdoorurl" />
Expand All @@ -248,7 +248,7 @@
</xMetaDiss:xMetaDiss>
</xsl:template>

<xsl:template match="TitleMain" mode="xmetadissplus">
<xsl:template match="TitleMain" mode="metadata_prefix_mode">
<dc:title xsi:type="ddb:titleISO639-2">
<xsl:attribute name="lang">
<xsl:value-of select="php:functionString('Opus\Common\Language::getLanguageCode', @Language)" />
Expand All @@ -264,7 +264,7 @@
</dc:title>
</xsl:template>

<xsl:template match="TitleSub" mode="xmetadissplus">
<xsl:template match="TitleSub" mode="metadata_prefix_mode">
<dcterms:alternative xsi:type="ddb:talternativeISO639-2">
<xsl:attribute name="lang">
<xsl:value-of select="php:functionString('Opus\Common\Language::getLanguageCode', @Language)" />
Expand All @@ -280,7 +280,7 @@
</dcterms:alternative>
</xsl:template>

<xsl:template match="PersonAuthor" mode="xmetadissplus">
<xsl:template match="PersonAuthor" mode="metadata_prefix_mode">
<dc:creator xsi:type="pc:MetaPers">
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
Expand Down Expand Up @@ -321,7 +321,7 @@
</dc:creator>
</xsl:template>

<xsl:template match="@CreatingCorporation" mode="xmetadissplus">
<xsl:template match="@CreatingCorporation" mode="metadata_prefix_mode">
<dc:creator xsi:type="pc:MetaPers">
<pc:person>
<pc:name type="otherName" otherNameType="organisation">
Expand All @@ -333,7 +333,7 @@
</dc:creator>
</xsl:template>

<xsl:template match="@ContributingCorporation" mode="xmetadissplus">
<xsl:template match="@ContributingCorporation" mode="metadata_prefix_mode">
<dc:creator xsi:type="pc:MetaPers">
<pc:person>
<pc:name type="otherName" otherNameType="organisation">
Expand All @@ -345,25 +345,25 @@
</dc:creator>
</xsl:template>

<xsl:template match="Collection[@RoleName='ddc' and @Visible=1]" mode="xmetadissplus">
<xsl:template match="Collection[@RoleName='ddc' and @Visible=1]" mode="metadata_prefix_mode">
<dc:subject xsi:type="xMetaDiss:DDC-SG">
<xsl:value-of select="@Number" />
</dc:subject>
</xsl:template>

<xsl:template match="Subject[@Type='swd']" mode="xmetadissplus">
<xsl:template match="Subject[@Type='swd']" mode="metadata_prefix_mode">
<dc:subject xsi:type="xMetaDiss:SWD">
<xsl:value-of select="@Value" />
</dc:subject>
</xsl:template>

<xsl:template match="Subject[@Type='uncontrolled']" mode="xmetadissplus">
<xsl:template match="Subject[@Type='uncontrolled']" mode="metadata_prefix_mode">
<dc:subject xsi:type="xMetaDiss:noScheme">
<xsl:value-of select="@Value" />
</dc:subject>
</xsl:template>

<xsl:template match="TitleAbstract" mode="xmetadissplus">
<xsl:template match="TitleAbstract" mode="metadata_prefix_mode">
<dcterms:abstract xsi:type="ddb:contentISO639-2" ddb:type="noScheme">
<xsl:attribute name="lang">
<xsl:value-of select="php:functionString('Opus\Common\Language::getLanguageCode', @Language)" />
Expand All @@ -372,7 +372,7 @@
</dcterms:abstract>
</xsl:template>

<xsl:template match="PersonAdvisor" mode="xmetadissplus">
<xsl:template match="PersonAdvisor" mode="metadata_prefix_mode">
<dc:contributor xsi:type="pc:Contributor" type="dcterms:ISO3166" thesis:role="advisor">
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
Expand Down Expand Up @@ -413,7 +413,7 @@
</dc:contributor>
</xsl:template>

<xsl:template match="PersonReferee" mode="xmetadissplus">
<xsl:template match="PersonReferee" mode="metadata_prefix_mode">
<dc:contributor xsi:type="pc:Contributor" type="dcterms:ISO3166" thesis:role="referee">
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
Expand Down Expand Up @@ -454,7 +454,7 @@
</dc:contributor>
</xsl:template>

<xsl:template match="PersonEditor" mode="xmetadissplus">
<xsl:template match="PersonEditor" mode="metadata_prefix_mode">
<dc:contributor xsi:type="pc:Contributor" type="dcterms:ISO3166" thesis:role="editor">
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
Expand Down Expand Up @@ -495,7 +495,7 @@
</dc:contributor>
</xsl:template>

<xsl:template match="ThesisPublisher" mode="xmetadissplus">
<xsl:template match="ThesisPublisher" mode="metadata_prefix_mode">
<dc:publisher xsi:type="cc:Publisher" type="dcterms:ISO3166">
<cc:universityOrInstitution>
<cc:name>
Expand All @@ -511,13 +511,13 @@
</dc:publisher>
</xsl:template>

<xsl:template match="Identifier[@Type = 'urn']" mode="xmetadissplus">
<xsl:template match="Identifier[@Type = 'urn']" mode="metadata_prefix_mode">
<dc:identifier xsi:type="urn:nbn">
<xsl:value-of select="@Value" />
</dc:identifier>
</xsl:template>

<xsl:template match="Identifier[@Type = 'doi']" mode="xmetadissplus">
<xsl:template match="Identifier[@Type = 'doi']" mode="metadata_prefix_mode">
<dc:identifier xsi:type="doi:doi">
<xsl:value-of select="@Value" />
</dc:identifier>
Expand All @@ -529,33 +529,33 @@
</ddb:identifier>
</xsl:template>

<xsl:template match="Licence" mode="xmetadissplus">
<xsl:template match="Licence" mode="metadata_prefix_mode">
<dc:rights>
<xsl:value-of select="@NameLong" />
</dc:rights>
</xsl:template>

<xsl:template match="File" mode="xmetadissplus">
<xsl:template match="File" mode="metadata_prefix_mode">
<ddb:fileProperties ddb:fileName="{@PathName}" ddb:fileSize="{@FileSize}">
<xsl:attribute name="ddb:fileID">
<xsl:text>file</xsl:text><xsl:value-of select="../@Id"/>-<xsl:value-of select="position()-1"/>
</xsl:attribute>
</ddb:fileProperties>
</xsl:template>

<xsl:template match="TransferUrl" mode="xmetadissplus">
<xsl:template match="TransferUrl" mode="metadata_prefix_mode">
<ddb:transfer ddb:type="dcterms:URI">
<xsl:value-of select="@PathName" />
</ddb:transfer>
</xsl:template>

<xsl:template match="Identifier[@Type = 'url']" mode="xmetadissplus">
<xsl:template match="Identifier[@Type = 'url']" mode="metadata_prefix_mode">
<ddb:identifier ddb:type="URL">
<xsl:value-of select="@Value" />
</ddb:identifier>
</xsl:template>

<xsl:template match="TitleParent" mode="xmetadissplus">
<xsl:template match="TitleParent" mode="metadata_prefix_mode">
<dc:source xsi:type="ddb:noScheme">
<xsl:value-of select="@Value" />
<xsl:if test="../@Volume != ''">
Expand All @@ -582,7 +582,7 @@
</dc:source>
</xsl:template>

<xsl:template match="Series" mode="xmetadissplus">
<xsl:template match="Series" mode="metadata_prefix_mode">
<dcterms:isPartOf xsi:type="ddb:noScheme">
<xsl:value-of select="@Title" />
<xsl:text> ; </xsl:text>
Expand Down
2 changes: 1 addition & 1 deletion modules/oai/views/scripts/index/prefixes/copy_xml.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<xsl:output method="xml" indent="yes" />

<xsl:template match="Opus_Document" mode="copy_xml">
<xsl:template match="Opus_Document" mode="metadata_prefix_mode">
<xsl:copy-of select="."/>
</xsl:template>

Expand Down
12 changes: 6 additions & 6 deletions modules/oai/views/scripts/index/prefixes/epicur.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<xsl:output method="xml" indent="yes" />

<xsl:template match="Opus_Document" mode="epicur">
<xsl:template match="Opus_Document" mode="metadata_prefix_mode">
<epicur
xsi:schemaLocation="urn:nbn:de:1111-2004033116 http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd"
xmlns="urn:nbn:de:1111-2004033116"
Expand All @@ -59,7 +59,7 @@

<record>
<!-- Identifier URN -->
<xsl:apply-templates select="Identifier[@Type = 'urn']" mode="epicur" />
<xsl:apply-templates select="Identifier[@Type = 'urn']" mode="metadata_prefix_mode" />

<resource>
<identifier scheme="url" role="primary">
Expand All @@ -71,24 +71,24 @@
</format>
</resource>

<xsl:apply-templates select="File" mode="epicur"/>
<xsl:apply-templates select="File" mode="metadata_prefix_mode"/>

</record>

</epicur>
</xsl:template>


<xsl:template match="Identifier[@Type = 'urn']" mode="epicur">
<xsl:template match="Identifier[@Type = 'urn']" mode="metadata_prefix_mode">
<identifier scheme="urn:nbn:de">
<xsl:value-of select="@Value" />
</identifier>
</xsl:template>

<!-- skip container file -->
<xsl:template match="File[@DnbContainer='1']" mode="epicur" />
<xsl:template match="File[@DnbContainer='1']" mode="metadata_prefix_mode" />

<xsl:template match="File" mode="epicur">
<xsl:template match="File" mode="metadata_prefix_mode">
<resource>
<identifier scheme="url">
<xsl:value-of select="@url"/>
Expand Down
Loading

0 comments on commit 5b44a67

Please sign in to comment.