Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/pazpar2
[pazpar2-moved-to-github.git] / etc / opac.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet
3     version="1.0"
4     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5     xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
6     xmlns:marc="http://www.loc.gov/MARC21/slim">
7   
8   <xsl:import href="marc21.xsl"/>
9
10   <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
11
12 <!-- Extract metadata from OPAC records with embedded MAR records
13       http://www.loc.gov/marc/bibliographic/ecbdhome.html
14 -->  
15
16   <xsl:template name="record-hook">
17     <xsl:for-each select="/opacRecord/holdings/holding">
18       <pz:metadata type="locallocation">
19         <xsl:choose>
20           <xsl:when test="localLocation">
21             <xsl:value-of select="localLocation"/>
22           </xsl:when>
23           <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
24         </xsl:choose>
25       </pz:metadata>
26       <pz:metadata type="callnumber">
27         <xsl:choose>
28           <xsl:when test="callNumber">
29             <xsl:value-of select="callNumber"/>
30           </xsl:when>
31           <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
32         </xsl:choose>
33       </pz:metadata>
34       <pz:metadata type="publicnote">
35         <xsl:choose>
36           <xsl:when test="publicNote">
37             <xsl:value-of select="publicNote"/>
38           </xsl:when>
39           <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
40         </xsl:choose>
41       </pz:metadata>
42       <pz:metadata type="available">
43         <xsl:choose>
44           <xsl:when test="circulations/circulation/availableNow/@value = '1'">
45              Available
46           </xsl:when>
47           <xsl:when test="circulations/circulation/availableNow/@value = '0'">
48              <xsl:choose>
49                <xsl:when test="circulations/circulation/availabiltyDate">
50                  <xsl:value-of select="circulations/circulation/availabiltyDate"/>
51                </xsl:when>
52                <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
53              </xsl:choose>
54           </xsl:when>
55           <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
56         </xsl:choose>
57       </pz:metadata>
58     </xsl:for-each>
59   </xsl:template>
60
61   <xsl:template match="/">
62     <xsl:choose>
63       <xsl:when test="opacRecord">
64         <xsl:apply-templates select="opacRecord/bibliographicRecord"/>
65       </xsl:when>
66       <xsl:otherwise>
67         <xsl:apply-templates/>
68       </xsl:otherwise>
69     </xsl:choose>
70   </xsl:template>
71
72 </xsl:stylesheet>