From f91e94c5ecda73eed38806f09986a591225dd0de Mon Sep 17 00:00:00 2001
From: David Maus <maus@hab.de>
Date: Fri, 6 Oct 2017 12:01:11 +0200
Subject: [PATCH] Static Repository erstellen

---
 .../{oais-resolve.xsl => oais-tei.xsl}        | 10 ++++++
 .../repertorium/oais-tei2dc.xsl}              | 11 +++---
 resources/xproc/repertorium/oais.xpl          |  5 ++-
 resources/xproc/repertorium/oais.xsl          | 34 ++++++++++++++-----
 4 files changed, 45 insertions(+), 15 deletions(-)
 rename resources/xproc/repertorium/{oais-resolve.xsl => oais-tei.xsl} (60%)
 rename resources/{xslt/repertorium/export-dc.xsl => xproc/repertorium/oais-tei2dc.xsl} (89%)

diff --git a/resources/xproc/repertorium/oais-resolve.xsl b/resources/xproc/repertorium/oais-tei.xsl
similarity index 60%
rename from resources/xproc/repertorium/oais-resolve.xsl
rename to resources/xproc/repertorium/oais-tei.xsl
index 7c7fcbc3..fe3e36ca 100644
--- a/resources/xproc/repertorium/oais-resolve.xsl
+++ b/resources/xproc/repertorium/oais-tei.xsl
@@ -1,5 +1,7 @@
 <xsl:transform version="2.0"
+               exclude-result-prefixes="#all"
                xpath-default-namespace="http://www.tei-c.org/ns/1.0"
+               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
   <xsl:template match="node() | @*">
@@ -8,6 +10,14 @@
     </xsl:copy>
   </xsl:template>
 
+  <xsl:template match="TEI">
+    <xsl:copy>
+      <xsl:attribute name="xsi:schemaLocation">http://www.tei-c.org/ns/1.0 http://selbstzeugnisse.hab.de/repertorium.xsd</xsl:attribute>
+      <xsl:apply-templates select="@* except @xsi:*"/>
+      <xsl:apply-templates select="node()"/>
+    </xsl:copy>
+  </xsl:template>
+
   <xsl:template match="@ref[starts-with(., '../../register.xml')]">
     <xsl:if test="document(.)/idno[@type = 'URI']">
       <xsl:attribute name="ref" select="document(.)/idno[@type = 'URI']"/>
diff --git a/resources/xslt/repertorium/export-dc.xsl b/resources/xproc/repertorium/oais-tei2dc.xsl
similarity index 89%
rename from resources/xslt/repertorium/export-dc.xsl
rename to resources/xproc/repertorium/oais-tei2dc.xsl
index 834ad3aa..b1f78c11 100644
--- a/resources/xslt/repertorium/export-dc.xsl
+++ b/resources/xproc/repertorium/oais-tei2dc.xsl
@@ -1,14 +1,13 @@
-<xsl:transform version="1.0"
-               exclude-result-prefixes="tei"
+<xsl:transform version="2.0"
+               exclude-result-prefixes="#all"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
                xmlns:tei="http://www.tei-c.org/ns/1.0"
+               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
-  <xsl:output method="xml" indent="yes"/>
-
   <xsl:template match="tei:msDesc">
-    <oai_dc:dc>
+    <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
       <xsl:apply-templates/>
     </oai_dc:dc>
   </xsl:template>
@@ -90,7 +89,7 @@
 
   <xsl:template match="tei:msItem">
     <dc:type>
-      <xsl:value-of select="id(substring(@class, 2))/tei:catDesc/tei:term"/>
+      <xsl:value-of select="document(@class)/tei:catDesc/tei:term"/>
     </dc:type>
     <xsl:apply-templates/>
   </xsl:template>
diff --git a/resources/xproc/repertorium/oais.xpl b/resources/xproc/repertorium/oais.xpl
index 0e69770e..a5dcec07 100644
--- a/resources/xproc/repertorium/oais.xpl
+++ b/resources/xproc/repertorium/oais.xpl
@@ -1,8 +1,11 @@
 <p:declare-step version="1.0"
+                exclude-inline-prefixes="#all"
                 xmlns:c="http://www.w3.org/ns/xproc-step"
                 xmlns:s="http://selbstzeugnisse.hab.de/ns"
                 xmlns:p="http://www.w3.org/ns/xproc">
 
+  <p:serialization method="xml" port="result"/>
+
   <p:import href="library.xpl"/>
 
   <p:documentation xmlns="http://www.w3.org/1999/xhtml">
@@ -20,7 +23,7 @@
     </p:load>
     <p:xslt>
       <p:input port="stylesheet">
-        <p:document href="oais-resolve.xsl"/>
+        <p:document href="oais-tei.xsl"/>
       </p:input>
       <p:input port="parameters">
         <p:empty/>
diff --git a/resources/xproc/repertorium/oais.xsl b/resources/xproc/repertorium/oais.xsl
index c3200c37..761345ee 100644
--- a/resources/xproc/repertorium/oais.xsl
+++ b/resources/xproc/repertorium/oais.xsl
@@ -1,10 +1,13 @@
 <xsl:transform version="2.0"
                xpath-default-namespace="http://www.tei-c.org/ns/1.0"
                xmlns="http://www.openarchives.org/OAI/2.0/static-repository"
+               xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:oai="http://www.openarchives.org/OAI/2.0/"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
+  <xsl:include href="oais-tei2dc.xsl"/>
+  
   <xsl:template match="/">
     <Repository xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/static-repository http://www.openarchives.org/OAI/2.0/static-repository.xsd">
       <Identify>
@@ -24,27 +27,42 @@
         </oai:metadataFormat>
         <oai:metadataFormat>
           <oai:metadataPrefix>tei</oai:metadataPrefix>
-          <oai:schema>http://selbstzeugnisse.hab.de/daten/oai-repertorium.xsd</oai:schema>
+          <oai:schema>http://selbstzeugnisse.hab.de/repertorium.xsd</oai:schema>
           <oai:metadataNamespace>http://www.tei-c.org/ns/1.0</oai:metadataNamespace>
         </oai:metadataFormat>
       </ListMetadataFormats>
       <ListRecords metadataPrefix="tei">
-        <xsl:apply-templates/>
+        <xsl:apply-templates mode="tei"/>
+      </ListRecords>
+      <ListRecords metadataPrefix="oai_dc">
+        <xsl:apply-templates mode="oai_dc"/>
       </ListRecords>
     </Repository>
   </xsl:template>
 
-  <xsl:template match="TEI">
-    <oai:record> 
-      <oai:header>
-        <oai:identifier><xsl:value-of select="concat('oai:selbstzeugnisse.hab.de:', @xml:id)"/></oai:identifier> 
-        <oai:datestamp><xsl:value-of select="format-date(current-date(), '[Y]-[M01]-[D01]')"/></oai:datestamp>
-      </oai:header>
+  <xsl:template match="TEI" mode="tei">
+    <oai:record>
+      <xsl:call-template name="header"/>
       <oai:metadata>
         <xsl:sequence select="."/>
       </oai:metadata>
     </oai:record>
   </xsl:template>
 
+  <xsl:template match="TEI" mode="oai_dc">
+    <oai:record>
+      <xsl:call-template name="header"/>
+      <oai:metadata>
+        <xsl:apply-templates select=".//msDesc"/>
+      </oai:metadata>
+    </oai:record>
+  </xsl:template>
+
+  <xsl:template name="header">
+    <oai:header>
+      <oai:identifier><xsl:value-of select="concat('oai:selbstzeugnisse.hab.de:', tokenize(@xml:id, '\.')[3])"/></oai:identifier> 
+      <oai:datestamp><xsl:value-of select="format-date(current-date(), '[Y]-[M01]-[D01]')"/></oai:datestamp>
+    </oai:header>
+  </xsl:template>
   
 </xsl:transform>
-- 
GitLab