Skip to content

Commit 35406c4

Browse files
committed
MIR-1564 Migrate mets-dfg to Saxon
1 parent 7ec51f1 commit 35406c4

File tree

6 files changed

+112
-132
lines changed

6 files changed

+112
-132
lines changed

mir-module/src/main/resources/config/mir/mycore.properties

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ MCR.RestApi.Draft.MCRAccessKey2=true
122122
# Configure DFGViewer #
123123
##############################################################################
124124
MIR.DFGViewer.enable=false
125-
MCR.ContentTransformer.mets-dfg.Class=org.mycore.common.content.transformer.MCRXSLTransformer
126-
MCR.ContentTransformer.mets-dfg.TransformerFactoryClass=%XALAN%
127-
MCR.ContentTransformer.mets-dfg.Stylesheet=xsl/mets/mets-dfg.xsl
125+
MCR.ContentTransformer.mets-dfg.Stylesheet=xslt/mets/mets-dfg.xsl
128126

129127
# add if DFGViewer is enabled (MIR.DFGViewer.enable=true)
130128
# MIR.DFGViewer.DV.Owner=

mir-module/src/main/resources/xsl/mets/mets-dfg.xsl

Lines changed: 0 additions & 8 deletions
This file was deleted.

mir-module/src/main/resources/xsl/mets/mets-amd.xsl renamed to mir-module/src/main/resources/xslt/mets/mets-amd.xsl

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<xsl:stylesheet version="1.0"
3-
xmlns:mcrxml="xalan://org.mycore.common.xml.MCRXMLFunctions"
2+
<xsl:stylesheet version="3.0"
3+
xmlns:mcrclassification="http://www.mycore.de/xslt/classification"
44
xmlns:mets="http://www.loc.gov/METS/"
55
xmlns:mods="http://www.loc.gov/mods/v3"
66
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7-
xmlns:xalan="http://xml.apache.org/xalan"
7+
xmlns:xlink="http://www.w3.org/1999/xlink"
88
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9-
exclude-result-prefixes="mcrxml xalan">
9+
exclude-result-prefixes="#all">
1010

11-
<xsl:param name="WebApplicationBaseURL" />
12-
<xsl:param name="objectID" />
1311
<xsl:param name="license" select="'CC-BY-NC-SA'" />
1412
<xsl:param name="MIR.DFGViewer.DV.Owner" select="''" />
1513
<xsl:param name="MIR.DFGViewer.DV.OwnerLogo" select="''" />
@@ -33,12 +31,11 @@
3331

3432
<xsl:variable name="derivateOwnerId">
3533
<xsl:choose>
36-
<!-- it is derivate -->
3734
<xsl:when test="$derobject">
38-
<xsl:value-of select="mcrxml:getMCRObjectID($derobject)" />
35+
<xsl:value-of
36+
select="(document(concat('mcrobject:', $derobject))/mycorederivate/derivate/linkmetas/linkmeta/@xlink:href, $objectID)[1]" />
3937
</xsl:when>
4038
<xsl:otherwise>
41-
<!--it is a regular mcrobj -->
4239
<xsl:value-of select="$mcrobject" />
4340
</xsl:otherwise>
4441
</xsl:choose>
@@ -53,17 +50,20 @@
5350
<mets:mdWrap MIMETYPE="text/xml" MDTYPE="OTHER" OTHERMDTYPE="DVRIGHTS">
5451
<mets:xmlData>
5552
<dv:rights xmlns:dv="http://dfg-viewer.de/">
56-
<!-- owner name -->
5753
<dv:owner><xsl:value-of select="$MIR.DFGViewer.DV.Owner" /></dv:owner>
5854
<dv:ownerLogo><xsl:value-of select="$MIR.DFGViewer.DV.OwnerLogo" /></dv:ownerLogo>
5955
<dv:ownerSiteURL><xsl:value-of select="$MIR.DFGViewer.DV.OwnerSiteURL" /></dv:ownerSiteURL>
60-
<dv:ownerContact/>
56+
<dv:ownerContact />
6157
<dv:license>
6258
<xsl:choose>
6359
<xsl:when test="$entity/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:accessCondition[@type='use and reproduction']">
64-
<xsl:variable name="licenseClass" select="'mir_licenses'" />
65-
<xsl:variable name="licenseId" select="substring-after($entity/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:accessCondition[@type='use and reproduction']/@xlink-href, '#')" />
66-
<xsl:value-of select="mcrxml:getDisplayName($licenseClass, $licenseId)" />
60+
<xsl:variable name="licenseId"
61+
select="substring-after($entity/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:accessCondition[@type='use and reproduction']/@xlink:href, '#')" />
62+
<xsl:value-of
63+
select="(
64+
mcrclassification:label-text($CurrentLang, mcrclassification:category('mir_licenses', $licenseId)),
65+
mcrclassification:label-text($DefaultLang, mcrclassification:category('mir_licenses', $licenseId))
66+
)[1]" />
6767
</xsl:when>
6868
<xsl:otherwise>
6969
<xsl:value-of select="$license" />
@@ -74,31 +74,28 @@
7474
</mets:xmlData>
7575
</mets:mdWrap>
7676
</mets:rightsMD>
77-
<mets:digiprovMD>
78-
<xsl:attribute name="ID">
79-
<xsl:value-of select="concat('digiprovMD',$sectionID)" />
80-
</xsl:attribute>
77+
<mets:digiprovMD ID="{concat('digiprovMD', $sectionID)}">
8178
<mets:mdWrap MIMETYPE="text/xml" MDTYPE="OTHER" OTHERMDTYPE="DVLINKS">
8279
<mets:xmlData>
8380
<dv:links xmlns:dv="http://dfg-viewer.de/">
8481
<xsl:variable name="ppn"
85-
select="substring-after($entity/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:identifier[@type='uri'], ':ppn:')" />
82+
select="substring-after($entity/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:identifier[@type='uri'], ':ppn:')" />
8683
<xsl:if test="$ppn">
8784
<dv:reference>
8885
<xsl:variable name="catalogURL"
89-
select="concat(substring-before($MIR.DFGViewer.DV.OPAC.CATALOG.URL, '{PPN}'), $ppn , substring-after($MIR.DFGViewer.DV.OPAC.CATALOG.URL, '{PPN}'))" />
86+
select="concat(substring-before($MIR.DFGViewer.DV.OPAC.CATALOG.URL, '{PPN}'), $ppn, substring-after($MIR.DFGViewer.DV.OPAC.CATALOG.URL, '{PPN}'))" />
9087
<xsl:variable name="uriResolved"
91-
select="document(concat($catalogURL,'?format=xml'))//rdf:Description[@rdf:about=normalize-space($catalogURL)]/*[local-name() = 'page']/@rdf:resource" />
88+
select="document(concat($catalogURL, '?format=xml'))//rdf:Description[@rdf:about=normalize-space($catalogURL)]/*[local-name()='page']/@rdf:resource" />
9289
<xsl:value-of select="$uriResolved" />
9390
</dv:reference>
9491
</xsl:if>
9592
<dv:presentation>
9693
<xsl:choose>
9794
<xsl:when test="$mcrobject">
98-
<xsl:value-of select="concat($WebApplicationBaseURL,'receive/',$mcrobject)" />
95+
<xsl:value-of select="concat($WebApplicationBaseURL, 'receive/', $mcrobject)" />
9996
</xsl:when>
10097
<xsl:when test="$derobject">
101-
<xsl:value-of select="concat($WebApplicationBaseURL,'receive/',mcrxml:getMCRObjectID($derobject))" />
98+
<xsl:value-of select="concat($WebApplicationBaseURL, 'receive/', $derivateOwnerId)" />
10299
</xsl:when>
103100
</xsl:choose>
104101
</dv:presentation>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet version="3.0"
3+
xmlns:mets="http://www.loc.gov/METS/"
4+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5+
exclude-result-prefixes="#all">
6+
7+
<xsl:output method="xml" encoding="utf-8" />
8+
9+
<xsl:include href="resource:xslt/default-parameters.xsl" />
10+
<xsl:include href="xslInclude:functions" />
11+
12+
<xsl:param name="MCR.Module-iview2.SupportedContentTypes" />
13+
<xsl:param name="objectID" />
14+
<xsl:param name="derivateID" select="substring-after(/mets:mets/mets:dmdSec/@ID, '_')" />
15+
<xsl:param name="MCR.Viewer.PDFCreatorURI" />
16+
17+
<xsl:param name="ThumbnailBaseURL" select="concat($ServletsBaseURL, 'MCRDFGThumbnail/')" />
18+
<xsl:param name="ImageBaseURL" select="concat($ServletsBaseURL, 'MCRDFGServlet/')" />
19+
<xsl:param name="WebApplicationServletsURL" select="concat($WebApplicationBaseURL, 'servlets/')" />
20+
<xsl:param name="copyFileGrp" select="()" />
21+
22+
<xsl:include href="resource:xslt/mets/mets-dfgProfile.xsl" />
23+
24+
</xsl:stylesheet>

mir-module/src/main/resources/xsl/mets/mets-dfgProfile.xsl renamed to mir-module/src/main/resources/xslt/mets/mets-dfgProfile.xsl

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<xsl:stylesheet version="1.0"
2+
<xsl:stylesheet version="3.0"
33
xmlns:mets="http://www.loc.gov/METS/"
4-
xmlns:xalan="http://xml.apache.org/xalan"
54
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6-
exclude-result-prefixes="">
5+
exclude-result-prefixes="#all">
76

8-
<xsl:include href="resource:xsl/mets/mets-iview.xsl" />
9-
<xsl:include href="resource:xsl/mets/mets-amd.xsl" />
10-
<xsl:include href="resource:xsl/mods-enhancer.xsl" />
7+
<xsl:include href="resource:xslt/mets/mets-iview.xsl" />
8+
<xsl:include href="resource:xslt/mets/mets-amd.xsl" />
9+
<xsl:include href="resource:xslt/utils/mods-enhancer.xsl" />
1110

12-
<xsl:output method="xml" encoding="utf-8" />
13-
<xsl:param name="MCR.Module-iview2.SupportedContentTypes" />
14-
<xsl:param name="ServletsBaseURL" />
15-
<xsl:param name="WebApplicationBaseURL" />
16-
<xsl:param name="derivateID" />
17-
<xsl:param name="objectID" />
18-
19-
<xsl:variable name="sourcedoc" select="document(concat('mcrobject:',$objectID))" />
11+
<xsl:variable name="sourcedoc" select="document(concat('mcrobject:', $objectID))" />
2012

2113
<xsl:template match="/mycoreobject" priority="0" mode="metsmeta" xmlns:mods="http://www.loc.gov/mods/v3">
22-
<xsl:apply-templates mode="mods2mods" />
14+
<xsl:apply-templates mode="mods2mods" />
2315
</xsl:template>
2416

2517
<xsl:template match="mycoreobject" priority="0" mode="fallBackEntity">
@@ -57,15 +49,15 @@
5749
<mets:mets>
5850
<xsl:if test="not(mets:dmdSec)">
5951
<xsl:variable name="emptyDMDSec">
60-
<mets:dmdSec ID="dmd_{$derivateID}"/>
52+
<mets:dmdSec ID="dmd_{$derivateID}" />
6153
</xsl:variable>
62-
<xsl:apply-templates select="xalan:nodeset($emptyDMDSec)" />
54+
<xsl:apply-templates select="$emptyDMDSec/mets:dmdSec" />
6355
</xsl:if>
6456
<xsl:if test="not(mets:amdSec)">
65-
<xsl:variable name="emptryAMDSec">
57+
<xsl:variable name="emptyAMDSec">
6658
<mets:amdSec />
6759
</xsl:variable>
68-
<xsl:apply-templates select="xalan:nodeset($emptryAMDSec)" />
60+
<xsl:apply-templates select="$emptyAMDSec/mets:amdSec" />
6961
</xsl:if>
7062
<xsl:apply-templates />
7163
</mets:mets>
@@ -75,20 +67,20 @@
7567
<mets:dmdSec ID="dmd_{$derivateID}">
7668
<mets:mdWrap MDTYPE="MODS">
7769
<mets:xmlData>
78-
<xsl:apply-templates mode="metsmeta" select="$sourcedoc/mycoreobject" />
79-
<!-- TODO: add configurable template
80-
<mods:extension>
81-
<mir:entities xmlns:mir="http://www.mycore.de/mir/ns/mods-entities">
82-
<mir:entity type="operator" xlink:type="extended"
83-
xlink:title="xxx">
84-
<mir:site xlink:type="locator" xlink:href="#" />
85-
<mir:logo xlink:type="resource" xlink:href="{$logoBaseUrl}xxx.svg" />
86-
<mir:full-logo xlink:type="resource" xlink:href="{$logoBaseUrl}xxx.svg" />
87-
</mir:entity>
88-
<xsl:apply-templates mode="entities" select="$sourcedoc/mycoreobject" />
89-
</mir:entities>
90-
</mods:extension>
91-
-->
70+
<xsl:apply-templates mode="metsmeta" select="$sourcedoc/mycoreobject" />
71+
<!-- TODO: add configurable template
72+
<mods:extension>
73+
<mir:entities xmlns:mir="http://www.mycore.de/mir/ns/mods-entities">
74+
<mir:entity type="operator" xlink:type="extended"
75+
xlink:title="xxx">
76+
<mir:site xlink:type="locator" xlink:href="#" />
77+
<mir:logo xlink:type="resource" xlink:href="{$logoBaseUrl}xxx.svg" />
78+
<mir:full-logo xlink:type="resource" xlink:href="{$logoBaseUrl}xxx.svg" />
79+
</mir:entity>
80+
<xsl:apply-templates mode="entities" select="$sourcedoc/mycoreobject" />
81+
</mir:entities>
82+
</mods:extension>
83+
-->
9284
</mets:xmlData>
9385
</mets:mdWrap>
9486
</mets:dmdSec>

0 commit comments

Comments
 (0)