Skip to content
Snippets Groups Projects
Commit 7e9638a0 authored by David Maus's avatar David Maus
Browse files

Normalisiere file/@ID und @FILEID

parent c096104e
No related branches found
No related tags found
No related merge requests found
...@@ -2,18 +2,24 @@ ...@@ -2,18 +2,24 @@
exclude-result-prefixes="#all" exclude-result-prefixes="#all"
xpath-default-namespace="http://www.loc.gov/METS/" xpath-default-namespace="http://www.loc.gov/METS/"
xmlns="http://www.loc.gov/METS/" xmlns="http://www.loc.gov/METS/"
xmlns:fun="tag:maus@hab.de,2018-02:XSLT"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Normalisiert die von Kitodo.Production erzeugte METS-Datei --> <!-- Normalisiert die von Kitodo.Production erzeugte METS-Datei -->
<xsl:param name="objectId" as="xs:string" required="yes"/>
<xsl:key name="files" match="file" use="@ID"/>
<xsl:template match="node() | @*"> <xsl:template match="node() | @*">
<xsl:copy><xsl:apply-templates select="node() | @*"/></xsl:copy> <xsl:copy><xsl:apply-templates select="node() | @*"/></xsl:copy>
</xsl:template> </xsl:template>
<xsl:template match="mets"> <xsl:template match="mets">
<xsl:copy> <mets OBJID="{$objectId}">
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:copy> </mets>
</xsl:template> </xsl:template>
<xsl:template match="metsHdr"> <xsl:template match="metsHdr">
...@@ -24,4 +30,17 @@ ...@@ -24,4 +30,17 @@
</metsHdr> </metsHdr>
</xsl:template> </xsl:template>
<xsl:template match="@ID[parent::file]">
<xsl:attribute name="ID" select="fun:normalize-fileId(..)"/>
</xsl:template>
<xsl:template match="@FILEID">
<xsl:attribute name="FILEID" select="fun:normalize-fileId(key('files', .))"/>
</xsl:template>
<xsl:function name="fun:normalize-fileId" as="xs:string">
<xsl:param name="file" as="element(file)"/>
<xsl:value-of select="string-join( ('image', if ($file/../@USE) then lower-case($file/../@USE) else (), tokenize($file/FLocat/@xlink:href, '/')[last()]), '.')"/>
</xsl:function>
</xsl:transform> </xsl:transform>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment