Single md:author with authors (;-separated) DBC-155
[pazpar2-moved-to-github.git] / etc / xsl / primo-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:tmarc="http://www.indexdata.com/turbomarc"
6   xmlns:prim="http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib"
7   xmlns:sear="http://www.exlibrisgroup.com/xsd/jaguar/search"
8   >
9   <xsl:output indent="yes" method="xml" version="1.0"
10     encoding="UTF-8" />
11   <xsl:template name="record-hook" />
12   <xsl:variable name="type" select="/opt/prim:PrimoNMBib/prim:display/prim:type"/>
13   <xsl:variable name="is_article" select="$type = 'article'" />
14   <xsl:variable name="fulltext" select="/opt/prim:PrimoNMBib/prim:delivery/prim:fulltext"/>
15   <xsl:variable name="has_fulltext">
16     <xsl:choose>
17       <xsl:when test="$fulltext = 'no_fulltext' ">
18         <xsl:text>no</xsl:text>
19       </xsl:when>
20       <xsl:when test="$fulltext = 'fulltext'">
21         <xsl:text>yes</xsl:text>
22       </xsl:when>
23       <xsl:otherwise>
24         <xsl:text>no</xsl:text>
25       </xsl:otherwise>
26     </xsl:choose>
27   </xsl:variable>
28
29   <xsl:template match="/">
30     <xsl:apply-templates />
31   </xsl:template>
32
33   <xsl:template match="sear:RESULT">
34     <pz:records>
35       <xsl:apply-templates />
36     </pz:records>
37   </xsl:template>
38
39   <xsl:template match="sear:DOC">
40     <pz:record>
41       <xsl:apply-templates />
42     </pz:record>
43   </xsl:template>
44
45   <xsl:template match="prim:PrimoNMBib">
46     <xsl:apply-templates />
47   </xsl:template>
48
49   <xsl:template match="prim:control">
50     <xsl:for-each select="prim:recordid">
51       <pz:metadata type="id">
52         <xsl:value-of select="."/>
53       </pz:metadata>
54     </xsl:for-each>
55   </xsl:template>
56
57   <xsl:template match="prim:addata">
58     <!--    <xsl:variable name="yearmonthday" select="@date" /> -->
59
60     <xsl:for-each select="prim:date">
61       <pz:metadata type="date">
62         <xsl:value-of select="substring(.,1,4)" />
63       </pz:metadata>
64       <pz:metadata type="journal-month">
65         <xsl:value-of select="substring(.,4,1)" />
66       </pz:metadata>
67     </xsl:for-each>
68
69     <xsl:for-each select="prim:volume">
70       <pz:metadata type="volume-number">
71         <xsl:value-of select="." />
72       </pz:metadata>
73     </xsl:for-each>
74
75     <xsl:for-each select="prim:issue">
76       <pz:metadata type="issue-number">
77         <xsl:value-of select="." />
78       </pz:metadata>
79     </xsl:for-each>
80
81     <xsl:for-each select="prim:spage">
82       <pz:metadata type="pages-number">
83         <xsl:value-of select="." />
84       </pz:metadata>
85     </xsl:for-each>
86
87     <xsl:for-each select="prim:issn">
88       <pz:metadata type="issn">
89         <xsl:value-of select="." />
90       </pz:metadata>
91     </xsl:for-each>
92
93     <xsl:for-each select="prim:jtitle">
94       <pz:metadata type="journal-title">
95         <xsl:value-of select="." />
96       </pz:metadata>
97     </xsl:for-each>
98   </xsl:template>
99
100   <xsl:template match="prim:delivery">
101     <xsl:if test="$has_fulltext">
102       <pz:metadata type="has-fulltext">
103         <xsl:value-of select="$has_fulltext" />
104       </pz:metadata>
105     </xsl:if>
106   </xsl:template>
107
108   <xsl:template match="prim:display">
109     <xsl:for-each select="prim:creator">
110        <pz:metadata type="author">
111          <xsl:value-of select="." />
112        </pz:metadata>
113     </xsl:for-each>
114     <xsl:for-each select="prim:type">
115       <xsl:variable name="type" select="."/>
116       <pz:metadata type="medium">
117         <xsl:choose>
118           <xsl:when test="$type ='article' and $has_fulltext = 'yes'">
119             <xsl:text>e-article</xsl:text>
120           </xsl:when>
121           <xsl:when  test="$type = 'article' and $has_fulltext = 'no'">
122             <xsl:text>article</xsl:text>
123           </xsl:when>
124           <xsl:otherwise>
125             <xsl:value-of select="$type"/>
126           </xsl:otherwise>
127         </xsl:choose>
128       </pz:metadata>
129       <pz:metadata type="debug_isarticle"><xsl:value-of select="$is_article"/></pz:metadata>
130     </xsl:for-each>
131
132     <xsl:for-each select="prim:title">
133       <pz:metadata type="title">
134         <xsl:value-of select="." />
135       </pz:metadata>
136     </xsl:for-each>
137
138     <xsl:for-each select="prim:ispartof">
139       <pz:metadata type="journal-subpart">
140         <xsl:value-of select="." />
141       </pz:metadata>
142       <pz:metadata type="citation">
143         <xsl:value-of select="." />
144       </pz:metadata>
145     </xsl:for-each>
146   </xsl:template>
147
148   <xsl:template match="prim:facets">
149     <xsl:for-each select="prim:topic">
150        <pz:metadata type="subject">
151         <xsl:value-of select="." />
152       </pz:metadata>
153     </xsl:for-each>
154   </xsl:template>
155
156   <xsl:template match="sear:LINKS" >
157     <xsl:for-each select="sear:openurl">
158       <pz:metadata type="electronic-url">
159         <xsl:value-of select="."/>
160       </pz:metadata>
161     </xsl:for-each>
162   </xsl:template>
163
164   <xsl:template match="prim:search">
165
166     <xsl:for-each select="prim:description">
167       <pz:metadata type="description">
168         <xsl:value-of select="." />
169       </pz:metadata>
170     </xsl:for-each>
171
172
173     <xsl:for-each select="prim:sub">
174       <pz:metadata type="subject">
175         <xsl:value-of select="." />
176       </pz:metadata>
177     </xsl:for-each>
178
179     <!-- passthrough id data -->
180     <xsl:for-each select="pz:metadata">
181       <xsl:copy-of select="." />
182     </xsl:for-each>
183     <!-- other stylesheets importing this might want to define this -->
184
185     <xsl:call-template name="record-hook" />
186   </xsl:template>
187
188   <xsl:template match="text()" />
189
190 </xsl:stylesheet>