Simplify XSLs by using new pz:metadata attribute 'empty'.
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 28 Feb 2013 12:51:53 +0000 (13:51 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 28 Feb 2013 12:51:53 +0000 (13:51 +0100)
etc/cf.xsl
etc/opac.xsl
etc/opac_turbomarc.xsl
etc/tmarc.xsl

index 324cdda..49c2a1a 100644 (file)
   -->
 
   <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="locallocation" empty="PAZPAR2_NULL_VALUE">
+      <xsl:value-of select="location"/>
     </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="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>
 
index e4c5457..dd5c789 100644 (file)
 
   <xsl:template name="record-hook">
     <xsl:for-each select="/opacRecord/holdings/holding">
-      <pz:metadata type="locallocation">
-        <xsl:choose>
-          <xsl:when test="localLocation">
-            <xsl:value-of select="localLocation"/>
-          </xsl:when>
-          <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-        </xsl:choose>
+      <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
+       <xsl:value-of select="localLocation"/>
       </pz:metadata>
-      <pz:metadata type="callnumber">
-        <xsl:choose>
-          <xsl:when test="callNumber">
-            <xsl:value-of select="callNumber"/>
-          </xsl:when>
-          <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-        </xsl:choose>
+      <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
+       <xsl:value-of select="callNumber"/>
       </pz:metadata>
-      <pz:metadata type="publicnote">
-        <xsl:choose>
-          <xsl:when test="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>
-      <pz:metadata type="available">
+      <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
         <xsl:choose>
           <xsl:when test="circulations/circulation/availableNow/@value = '1'">
              Available
           </xsl:when>
           <xsl:when test="circulations/circulation/availableNow/@value = '0'">
-             <xsl:choose>
-               <xsl:when test="circulations/circulation/availabiltyDate">
-                 <xsl:value-of select="circulations/circulation/availabiltyDate"/>
-               </xsl:when>
-               <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-             </xsl:choose>
-          </xsl:when>
-          <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
+           <xsl:value-of select="circulations/circulation/availabiltyDate"/>
+         </xsl:when>
         </xsl:choose>
       </pz:metadata>
     </xsl:for-each>
index 83d2319..98f33b7 100644 (file)
 
   <xsl:template name="record-hook">
     <xsl:for-each select="/opacRecord/holdings/holding">
-      <pz:metadata type="locallocation">
-        <xsl:choose>
-          <xsl:when test="localLocation">
-            <xsl:value-of select="localLocation"/>
-          </xsl:when>
-          <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-        </xsl:choose>
+      <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
+       <xsl:value-of select="localLocation"/>
       </pz:metadata>
-      <pz:metadata type="callnumber">
-        <xsl:choose>
-          <xsl:when test="callNumber">
-            <xsl:value-of select="callNumber"/>
-          </xsl:when>
-          <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-        </xsl:choose>
+      <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
+       <xsl:value-of select="callNumber"/>
       </pz:metadata>
-      <pz:metadata type="publicnote">
-        <xsl:choose>
-          <xsl:when test="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>
-      <pz:metadata type="available">
+      <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
         <xsl:choose>
           <xsl:when test="circulations/circulation/availableNow/@value = '1'">
              Available
           </xsl:when>
           <xsl:when test="circulations/circulation/availableNow/@value = '0'">
-             <xsl:choose>
-               <xsl:when test="circulations/circulation/availabiltyDate">
-                 <xsl:value-of select="circulations/circulation/availabiltyDate"/>
-               </xsl:when>
-               <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-             </xsl:choose>
-          </xsl:when>
-          <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
+           <xsl:value-of select="circulations/circulation/availabiltyDate"/>
+         </xsl:when>
         </xsl:choose>
       </pz:metadata>
     </xsl:for-each>
index c8eb90c..3d21381 100644 (file)
              <xsl:value-of select="$pages"/>
            </pz:metadata>
          </xsl:if>
-         
+
          <!-- season -->
         </xsl:if>
         <xsl:if test="tmarc:sp">
       </xsl:for-each>
 
       <xsl:for-each select="tmarc:d926">
-        <pz:metadata type="locallocation">
-         <xsl:choose><xsl:when test="tmarc:sa">
-           <xsl:value-of select="tmarc:sa"/>
-         </xsl:when><xsl:otherwise>
-           <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
-         </xsl:otherwise></xsl:choose>
+        <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
+         <xsl:value-of select="tmarc:sa"/>
        </pz:metadata>
-        <pz:metadata type="callnumber">
-         <xsl:choose><xsl:when test="tmarc:sc">
-           <xsl:value-of select="tmarc:sc"/>
-         </xsl:when><xsl:otherwise>
-           <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
-         </xsl:otherwise></xsl:choose>
+        <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
+         <xsl:value-of select="tmarc:sc"/>
        </pz:metadata>
-        <pz:metadata type="available">
-         <xsl:choose><xsl:when test="tmarc:se">
-           <xsl:value-of select="tmarc:se"/>
-         </xsl:when><xsl:otherwise>
-           <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
-         </xsl:otherwise></xsl:choose>
+        <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
+         <xsl:value-of select="tmarc:se"/>
        </pz:metadata>
       </xsl:for-each>
 
       <!-- OhioLINK holdings -->
       <xsl:for-each select="tmarc:d945">
-       <pz:metadata type="locallocation">
-          <xsl:choose>
-            <xsl:when test="tmarc:sa">
-              <xsl:value-of select="tmarc:sa"/>
-            </xsl:when>
-            <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-          </xsl:choose>
+       <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
+         <xsl:value-of select="tmarc:sa"/>
        </pz:metadata>
-       <pz:metadata type="callnumber">
-          <xsl:choose>
-           <xsl:when test="tmarc:sb">
-              <xsl:value-of select="tmarc:sb"/>
-            </xsl:when>
-            <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-          </xsl:choose>
+       <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
+         <xsl:value-of select="tmarc:sb"/>
        </pz:metadata>
-       <pz:metadata type="publicnote">
-          <xsl:choose>
-            <xsl:when test="tmarc:sc">
-              <xsl:value-of select="tmarc:sc"/>
-            </xsl:when>
-            <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-          </xsl:choose>
+       <pz:metadata type="publicnote" empty="PAZPAR2_NULL_VALUE">
+         <xsl:value-of select="tmarc:sc"/>
        </pz:metadata>
-       <pz:metadata type="available">
+       <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
           <xsl:choose>
             <xsl:when test="tmarc:ss = 'N'">Available</xsl:when>
-            <xsl:when test="tmarc:ss != 'N'">
-              <xsl:choose>
-               <xsl:when test="tmarc:sd">
-                  <xsl:value-of select="tmarc:sd"/>
-               </xsl:when>
-               <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-              </xsl:choose>
-            </xsl:when>
-            <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
-          </xsl:choose>
-       </pz:metadata>      
+            <xsl:otherwise>
+             <xsl:value-of select="tmarc:sd"/>
+           </xsl:otherwise>
+         </xsl:choose>
+       </pz:metadata>
       </xsl:for-each>
 
       <xsl:for-each select="tmarc:d948">