Changes requested by D.
[pazpar2-moved-to-github.git] / etc / dads-pz2.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
4   xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
5   xmlns:zs="http://www.loc.gov/zing/srw/"
6   xmlns:tmarc="http://www.indexdata.com/turbomarc">
7
8   <xsl:output indent="yes" method="xml" version="1.0"
9     encoding="UTF-8" />
10   <xsl:param name="medium"/>
11
12   <!-- Extract metadata from MARC21/USMARC from streamlined marcxml format 
13     http://www.loc.gov/marc/bibliographic/ecbdhome.html -->
14   <xsl:template name="record-hook" />
15
16
17   <xsl:template match="/">
18       <xsl:apply-templates />
19   </xsl:template>
20
21   <xsl:template match="zs:searchRetrieveResponse">
22       <xsl:apply-templates />
23   </xsl:template>
24
25   <xsl:template match="zs:records">
26     <collection>
27       <xsl:apply-templates />
28     </collection>
29   </xsl:template>
30
31   <xsl:template match="zs:record">
32       <xsl:apply-templates />
33   </xsl:template>  
34
35   <xsl:template match="zs:recordData">
36       <xsl:apply-templates />
37   </xsl:template>
38
39   <xsl:template match="doc">
40     <collection>
41       <xsl:apply-templates />
42     </collection>
43   </xsl:template>
44
45   <xsl:template match="art">
46     <xsl:variable name="journal_title" select="journal/title" />
47     <xsl:variable name="journal_issn" select="journal/issn" />
48     <xsl:variable name="date" select="journal/year" />
49     <xsl:variable name="description" select="abstract/abstract" />
50
51     <xsl:variable name="has_fulltext" select="article/fulltext"/>
52     <xsl:variable name="has_title" select="article/title"/>
53
54     <xsl:variable name="vmedium">
55       <xsl:choose>
56         <xsl:when  test="$has_title and $has_fulltext">
57           <xsl:text>e-article</xsl:text>
58         </xsl:when>
59         <xsl:when  test="$has_title and not($has_fulltext)">
60           <xsl:text>article</xsl:text>
61         </xsl:when>
62         <xsl:otherwise>
63           <xsl:text>other</xsl:text>
64         </xsl:otherwise>
65       </xsl:choose>
66     </xsl:variable>
67     
68     <pz:record>
69
70       <xsl:for-each select="localInfo/systemno"> 
71         <pz:metadata type="id">
72           <xsl:value-of select="."/>
73         </pz:metadata>
74       </xsl:for-each>
75
76       <xsl:for-each select="author/name">
77         <pz:metadata type="author">
78           <xsl:value-of select="." />
79         </pz:metadata>
80       </xsl:for-each>
81       
82       <xsl:for-each select="article/title">
83         <pz:metadata type="title">
84           <xsl:value-of select="." />
85         </pz:metadata>
86       </xsl:for-each>
87
88       <xsl:for-each select="journal/issn">
89         <pz:metadata type="issn">
90           <xsl:value-of select="." />
91         </pz:metadata>
92       </xsl:for-each>
93
94       <xsl:for-each select="journal/title">
95         <pz:metadata type="journal-title">
96           <xsl:value-of select="." />
97         </pz:metadata>
98       </xsl:for-each>
99
100       <xsl:for-each select="journal/vol">
101         <pz:metadata type="journal-number">
102           <xsl:value-of select="." />
103         </pz:metadata>
104       </xsl:for-each>
105
106       <xsl:for-each select="journal/issue">
107         <pz:metadata type="issue-number">
108           <xsl:value-of select="." />
109         </pz:metadata>
110       </xsl:for-each>
111
112       <xsl:for-each select="journal"> 
113         <pz:metadata type="journal-subpart">
114           <xsl:text>Vol. </xsl:text><xsl:value-of select="vol" /><xsl:text>,</xsl:text>
115           <xsl:if test="issue">
116             <xsl:text> no. </xsl:text><xsl:value-of select="issue" />
117           </xsl:if>
118           <xsl:text> (</xsl:text>
119           <xsl:choose>
120             <xsl:when test="month='01'">
121               <xsl:text>Jan. </xsl:text>
122             </xsl:when>
123             <xsl:when test="month='02'">
124               <xsl:text>Feb. </xsl:text>
125             </xsl:when>
126             <xsl:when test="month='03'">
127               <xsl:text>Mar. </xsl:text>
128             </xsl:when>
129             <xsl:when test="month='04'">
130               <xsl:text>Apr. </xsl:text>
131             </xsl:when>
132             <xsl:when test="month='05'">
133               <xsl:text>May </xsl:text>
134             </xsl:when>
135             <xsl:when test="month='06'">
136               <xsl:text>June </xsl:text>
137             </xsl:when>
138             <xsl:when test="month='07'">
139               <xsl:text>July </xsl:text>
140             </xsl:when>
141             <xsl:when test="month='08'">
142               <xsl:text>Aug. </xsl:text>
143             </xsl:when>
144             <xsl:when test="month='09'">
145               <xsl:text>Sept. </xsl:text>
146             </xsl:when>
147             <xsl:when test="month='10'">
148               <xsl:text>Oct. </xsl:text>
149             </xsl:when>
150             <xsl:when test="month='11'">
151               <xsl:text>Nov. </xsl:text>
152             </xsl:when>
153             <xsl:when test="month='12'">
154               <xsl:text>Dec. </xsl:text>
155             </xsl:when>
156             <xsl:otherwise>
157               <xsl:value-of select="month"/><xsl:text> </xsl:text>
158             </xsl:otherwise>
159           </xsl:choose>
160           <xsl:value-of select="year" /><xsl:text>)</xsl:text>
161           <xsl:if test="page"> 
162             <xsl:text>, p. </xsl:text><xsl:value-of select="page" />
163           </xsl:if>
164         </pz:metadata>
165       </xsl:for-each>      
166
167       <pz:metadata type="description">
168         <xsl:value-of select="$description" />
169       </pz:metadata>
170       
171       <xsl:for-each select="ctrlT/term">
172         <pz:metadata type="subject">
173           <xsl:value-of select="." />
174         </pz:metadata>
175       </xsl:for-each>
176
177       <xsl:for-each select="article/fulltext">
178         <pz:metadata type="fulltext">
179           <xsl:value-of select="." />
180         </pz:metadata>
181       </xsl:for-each>
182
183       <pz:metadata type="medium">
184         <xsl:value-of select="$vmedium" />
185 <!--
186         <xsl:if test="string-length($electronic) and $vmedium != 'electronic'">
187           <xsl:text> (electronic)</xsl:text>
188         </xsl:if>
189 -->
190       </pz:metadata>
191
192
193       <!-- passthrough id data -->
194       <xsl:for-each select="pz:metadata">
195         <xsl:copy-of select="." />
196       </xsl:for-each>
197
198       <!-- other stylesheets importing this might want to define this -->
199       <xsl:call-template name="record-hook" />
200         
201     </pz:record>
202
203   </xsl:template>
204
205   <xsl:template match="text()" />
206
207 </xsl:stylesheet>