From 3fef9c883f9116d13d46ea39260f03e5f0db2ada Mon Sep 17 00:00:00 2001
From: David Maus <maus@hab.de>
Date: Mon, 19 Feb 2018 11:26:33 +0100
Subject: [PATCH] =?UTF-8?q?Erzeuge=20PREMIS:EVENT=20f=C3=BCr=20Normalisier?=
 =?UTF-8?q?ung?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/xproc/publish.xpl | 24 +++++++++++++++++-------
 src/xslt/mets.xsl     | 17 ++++++++++++++++-
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/xproc/publish.xpl b/src/xproc/publish.xpl
index 13d3a29..fa74938 100644
--- a/src/xproc/publish.xpl
+++ b/src/xproc/publish.xpl
@@ -6,13 +6,20 @@
   <p:option name="objectId"  required="true"/>
   <p:option name="targetUri" required="true"/>
 
-  <p:uuid name="uuid-source" version="4" match="@create">
-    <p:input port="source">
-      <p:inline>
-        <uuid create=""/>
-      </p:inline>
-    </p:input>
-  </p:uuid>
+  <p:group name="uuid-source">
+    <p:output port="result"/>
+    <p:identity>
+      <p:input port="source">
+        <p:inline>
+          <uuid/>
+        </p:inline>
+      </p:input>
+    </p:identity>
+    <p:add-attribute match="uuid" attribute-name="create" attribute-value=""/>
+    <p:uuid version="4" match="@create"/>
+    <p:add-attribute match="uuid" attribute-name="normalize" attribute-value=""/>
+    <p:uuid version="4" match="@normalize"/>
+  </p:group>
 
   <p:choose>
     <p:when test="doc-available(resolve-uri($targetUri))">
@@ -42,6 +49,9 @@
         <p:with-param name="eventCreateUUID" select="/uuid/@create">
           <p:pipe step="uuid-source" port="result"/>
         </p:with-param>
+        <p:with-param name="eventNormalizeUUID" select="/uuid/@normalize">
+          <p:pipe step="uuid-source" port="result"/>
+        </p:with-param>
         <p:input port="source">
           <p:pipe step="validate-kitodo" port="result"/>
         </p:input>
diff --git a/src/xslt/mets.xsl b/src/xslt/mets.xsl
index 06f0380..1e0bd57 100644
--- a/src/xslt/mets.xsl
+++ b/src/xslt/mets.xsl
@@ -12,6 +12,7 @@
   <!-- Normalisiert die von Kitodo.Production erzeugte METS-Datei -->
   <xsl:param name="objectId" as="xs:string" required="yes"/>
   <xsl:param name="eventCreateUUID" as="xs:string" required="yes"/>
+  <xsl:param name="eventNormalizeUUID" as="xs:string" required="yes"/>
 
   <xsl:key name="files" match="file" use="@ID"/>
 
@@ -46,6 +47,20 @@
           </xmlData>
         </mdWrap>
       </digiprovMD>
+      <digiprovMD ID="id.{$eventNormalizeUUID}" CREATED="{current-dateTime()}">
+        <mdWrap MDTYPE="PREMIS:EVENT">
+          <xmlData>
+            <premis:event xmlns:premis="http://www.loc.gov/premis/v3">
+              <premis:eventIdentifier>
+                <premis:eventIdentifierType>UUID</premis:eventIdentifierType>
+                <premis:eventIdentifierValue><xsl:value-of select="$eventNormalizeUUID"/></premis:eventIdentifierValue>
+              </premis:eventIdentifier>
+              <premis:eventType valueURI="http://id.loc.gov/vocabulary/preservation/eventType/normalization">normalization</premis:eventType>
+              <premis:eventDataTime><xsl:value-of select="current-dateTime()"/></premis:eventDataTime>
+            </premis:event>
+          </xmlData>
+        </mdWrap>
+      </digiprovMD>
     </amdSec>
   </xsl:template>
 
@@ -58,7 +73,7 @@
   </xsl:template>
 
   <xsl:template match="metsHdr">
-    <metsHdr CREATEDATE="{@CREATEDATE}" LASTMODDATE="{current-dateTime()}" ADMID="id.{$eventCreateUUID}">
+    <metsHdr CREATEDATE="{@CREATEDATE}" LASTMODDATE="{current-dateTime()}" ADMID="id.{$eventCreateUUID} id.{$eventNormalizeUUID}">
       <agent ROLE="CUSTODIAN" TYPE="ORGANIZATION">
         <name>Herzog August Bibliothek Wolfenbüttel</name>
       </agent>
-- 
GitLab