XSL files now in sync with future 1.7 series
[pazpar2-moved-to-github.git] / etc / cf.xsl
index 324cdda..61edc04 100644 (file)
 
   <xsl:param name="medium" />
 
-  <!--
-    According to cf/builder/templates/parseTask.cff, connectors can
-    also generate a "medium" field, but that is ignored in this
-    stylesheet, the rule below instead using an XSLT parameter.
-    Should the data element be used in preference when it is included?
-  -->
-
+  <!-- Use medium parameter if given. Default to medium from connector -->
   <xsl:template match="/record">
     <pz:record>
       <pz:metadata type="medium">
-         <xsl:value-of select="$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 match="item">
-    <pz:metadata type="locallocation">
-      <xsl:choose>
-       <xsl:when test="string-length(location)">
-         <xsl:value-of select="location"/>
-       </xsl:when>
-       <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-      </xsl:choose>
+    <pz:metadata type="due" empty="PAZPAR2_NULL_VALUE">
+      <xsl:value-of select="due"/>
     </pz:metadata>
-    <pz:metadata type="callnumber">
-      <xsl:choose>
-       <xsl:when test="string-length(callno)">
-         <xsl:value-of select="callno"/>
-       </xsl:when>
-       <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-      </xsl:choose>
+    <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">
-      <xsl:choose>
-       <xsl:when test="string-length(available)">
-         <xsl:value-of select="available"/>
-       </xsl:when>
-       <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-      </xsl:choose>
+    <pz:metadata type="available" empty="PAZPAR_NULL_VALUE">
+      <xsl:value-of select="available"/>
     </pz:metadata>
-    <pz:metadata type="publicnote">
-      <xsl:choose>
-       <xsl:when test="string-length(publicnote)">
-         <xsl:value-of select="publicnote"/>
-       </xsl:when>
-       <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-      </xsl:choose>
+    <pz:metadata type="publicnote" empty="PAZPAR2_NULL_VALUE">
+      <xsl:value-of select="publicnote"/>
     </pz:metadata>
   </xsl:template>
 
       <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()}">