XSL files now in sync with future 1.7 series
[pazpar2-moved-to-github.git] / etc / cf.xsl
index 78f264c..61edc04 100644 (file)
@@ -1,9 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-
     This stylesheet expects Connector Frameworks records
-    $Id: usco.xsl,v 1.3 2009-01-13 15:18:42 wosch Exp $
-
 -->
 <xsl:stylesheet
     version="1.0"
         version="1.0"
         encoding="UTF-8"/>
 
+  <xsl:param name="medium" />
+
+  <!-- Use medium parameter if given. Default to medium from connector -->
   <xsl:template match="/record">
     <pz:record>
+      <pz:metadata type="medium">
+        <xsl:choose>
+          <xsl:when test="string-length($medium)">
+            <xsl:value-of select="$medium" />
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:if test="medium">
+             <xsl:value-of select="medium" />
+            </xsl:if>
+          </xsl:otherwise>
+        </xsl:choose>
+      </pz:metadata>
+      <xsl:apply-templates/>
+    </pz:record>
+  </xsl:template>
 
-      <xsl:attribute name="mergekey">
-       <xsl:text>title </xsl:text>
-        <xsl:value-of select="title" />
-       <xsl:text> author </xsl:text>
-        <xsl:value-of select="author"/>
-      </xsl:attribute>
+  <!--
+      The elements mapped in the following clauses should be kept more
+      or less in sync with those named in builder/templates/search.cft
+      in the "cf" git module.
+  -->
 
-      <pz:metadata type="id">
-        <xsl:value-of select="url"/>
-      </pz:metadata>
+  <xsl:template match="date">
+    <pz:metadata type="publication-date">
+      <xsl:value-of select="."/>
+    </pz:metadata>
+    <pz:metadata type="date">
+      <xsl:value-of select="."/>
+    </pz:metadata>
+  </xsl:template>
 
-      <pz:metadata type="author">
-        <xsl:value-of select="author"/>
-      </pz:metadata>
+  <xsl:template match="url">
+    <pz:metadata type="electronic-url">
+      <xsl:value-of select="."/>
+    </pz:metadata>
+  </xsl:template>
 
-        <pz:metadata type="title">
-          <xsl:value-of select="title" />
-        </pz:metadata>
+  <xsl:template match="title">
+    <pz:metadata type="title">
+      <xsl:value-of select="."/>
+    </pz:metadata>
+    <pz:metadata type="title-complete">
+      <xsl:value-of select="." />
+    </pz:metadata>
+  </xsl:template>
 
-        <pz:metadata type="date">
-          <xsl:value-of select="date" />
-        </pz:metadata>
+  <xsl:template match="journaltitle">
+    <pz:metadata type="journal-title">
+      <xsl:value-of select="."/>
+    </pz:metadata>
+  </xsl:template>
 
-        <pz:metadata type="electronic-url">
-          <xsl:value-of select="url" />
-        </pz:metadata>
+  <!--
+    According to cf/builder/templates/parseTask.cff, connectors can
+    also generate a "holding" field, but it's not clear how that is
+    different from "item".  Perhaps this "item" rule should also
+    handle "holding" in the same way?
+  -->
 
-    </pz:record>
+  <xsl:template match="item">
+    <pz:metadata type="due" empty="PAZPAR2_NULL_VALUE">
+      <xsl:value-of select="due"/>
+    </pz:metadata>
+    <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
+      <xsl:value-of select="location"/>
+    </pz:metadata>
+    <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
+      <xsl:value-of select="callno"/>
+    </pz:metadata>
+    <pz:metadata type="available" empty="PAZPAR_NULL_VALUE">
+      <xsl:value-of select="available"/>
+    </pz:metadata>
+    <pz:metadata type="publicnote" empty="PAZPAR2_NULL_VALUE">
+      <xsl:value-of select="publicnote"/>
+    </pz:metadata>
+  </xsl:template>
+
+  <xsl:template match="location">
+    <pz:metadata type="locallocation">
+      <xsl:value-of select="."/>
+    </pz:metadata>
+  </xsl:template>
+
+  <xsl:template match="callno">
+    <pz:metadata type="callnumber">
+      <xsl:value-of select="."/>
+    </pz:metadata>
+  </xsl:template>
+  
+  <!-- no-op template to avoid printing medium out --> 
+  <xsl:template match="medium" />
+
+  <xsl:template match="*" >
+    <pz:metadata type="{local-name()}">
+      <xsl:value-of select="."/>
+    </pz:metadata>
   </xsl:template>
 
   <xsl:template match="text()"/>