Merge branch 'master' of git.evergreen-ils.org:Evergreen into template-toolkit-opac
[working/Evergreen.git] / Open-ILS / xsl / MARC21slim2HTMLCard.xsl
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2   
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4   xmlns="http://www.w3.org/1999/xhtml"
5   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6   xmlns:marc="http://www.loc.gov/MARC21/slim"
7   xmlns:hold="http://open-ils.org/spec/holdings/v1"
8   version="1.0">
9   <xsl:output method="html" doctype-public="-//W3C/DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" />    
10   <xsl:template match="/">
11      <html>
12        <head>
13          <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
14          <link href="{$base_dir}/htmlcard.css" rel="stylesheet" type="text/css" />
15        </head>
16        <body>
17         <xsl:apply-templates select="//marc:record"/>
18        </body>
19      </html>
20   </xsl:template>
21       
22   <xsl:template match="marc:record">
23     <div class="cardimage">
24      <xsl:apply-templates select="marc:datafield[@tag!='082' and @tag!='092' and @tag!='010']"/>
25      <span class="bottom">
26       <xsl:apply-templates select="marc:controlfield[@tag='001']"/>
27       <xsl:apply-templates select="marc:datafield[@tag='082' or @tag='092' or @tag='010']"/>
28      </span>
29     </div>
30   </xsl:template>
31
32   <xsl:template match="marc:controlfield">
33       <span class="oclc">#<xsl:value-of select="substring(.,4)"/></span>
34   </xsl:template>
35       
36   <xsl:template match="marc:datafield">
37     <xsl:if test="starts-with(@tag, '1')">
38       <p class="mainheading"><xsl:value-of select="."/></p>
39     </xsl:if>
40
41     <xsl:if test="starts-with(@tag, '24') and /marc:record/marc:datafield[@tag='100']">
42       <span class="title"><xsl:value-of select="."/></span>
43     </xsl:if>
44
45     <xsl:if test="starts-with(@tag, '24') and not(/marc:record/marc:datafield[@tag='100'])">
46       <span class="titlemain"><xsl:value-of select="."/></span><br/>
47     </xsl:if>
48
49     <xsl:if test="@tag='260'">
50       <xsl:value-of select="."/>
51     </xsl:if>
52
53     <xsl:if test="@tag='300'">
54       <p class="extent"><xsl:value-of select="."/></p>
55      </xsl:if>
56
57     <xsl:if test="starts-with(@tag, '5')">
58       <p class="note"><xsl:value-of select="."/></p>
59     </xsl:if>
60
61     <xsl:if test="@tag='650'">
62       <span class='counter'><xsl:number count="marc:datafield[@tag='650']"/>.</span> <xsl:apply-templates select="marc:subfield"/>
63     </xsl:if>
64
65     <xsl:if test="@tag='653'">
66       <span class="counter"><xsl:number format="i" count="marc:datafield[@tag='653']"/>.</span> <xsl:apply-templates select="marc:subfield"/>
67     </xsl:if>
68
69     <xsl:if test="@tag='010'">
70       <xsl:variable name="LCCN.nospace" select="translate(., ' ', '')"/>
71       <xsl:variable name="LCCN.length" select="string-length($LCCN.nospace)"/>
72       <xsl:variable name="LCCN.display" select="concat(substring($LCCN.nospace, 1, $LCCN.length - 6), '-', format-number(substring($LCCN.nospace, $LCCN.length - 5),'#'))"/>
73       <span class="LCCN">LCCN:<xsl:value-of select="$LCCN.display"/></span>
74     </xsl:if>
75
76     <xsl:if test="@tag='082' or @tag='092'">
77       <span class="DDC"><xsl:value-of select="marc:subfield[@code='a']"/></span>
78     </xsl:if>
79
80     <xsl:if test="@tag='856'">
81      <br/><xsl:apply-templates mode="link" select="marc:subfield" />
82     </xsl:if>
83   </xsl:template>
84
85   <xsl:template match="marc:subfield" mode="link">
86     <xsl:if test="@code='u'">
87       <span class="link">
88         <a class="url" href="{.}">
89                 <xsl:choose>
90                         <xsl:when test="../marc:subfield[@code='y']">
91                                 <xsl:value-of select="../marc:subfield[@code='y']"/>
92                         </xsl:when>
93                         <xsl:when test="../marc:subfield[@code='3']">
94                                 <xsl:value-of select="../marc:subfield[@code='3']"/>
95                         </xsl:when>
96                         <xsl:otherwise>
97                                 <xsl:value-of select="."/>
98                         </xsl:otherwise>
99                 </xsl:choose>
100         </a>
101       </span>
102     </xsl:if>
103   </xsl:template>
104   
105   <xsl:template match="marc:subfield">
106     <xsl:if test="@code!='2'">    
107      <xsl:if test="@code!='a'">--</xsl:if>
108      <xsl:value-of select="."/>
109     </xsl:if>
110   </xsl:template>
111
112 </xsl:stylesheet>