031cb47a9e807d9bdb70ac452277e0032f4d905b
[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:type">
110       <xsl:variable name="type" select="."/>
111       <pz:metadata type="medium">
112         <xsl:choose>
113           <xsl:when test="$type ='article' and $has_fulltext = 'yes'">
114             <xsl:text>e-article</xsl:text>
115           </xsl:when>
116           <xsl:when  test="$type = 'article' and $has_fulltext = 'no'">
117             <xsl:text>article</xsl:text>
118           </xsl:when>
119           <xsl:otherwise>
120             <xsl:value-of select="$type"/>
121           </xsl:otherwise>
122         </xsl:choose>
123       </pz:metadata>
124       <pz:metadata type="debug_isarticle"><xsl:value-of select="$is_article"/></pz:metadata>
125     </xsl:for-each>
126
127     <xsl:for-each select="prim:title">
128       <pz:metadata type="title">
129         <xsl:value-of select="." />
130       </pz:metadata>
131     </xsl:for-each>
132
133     <xsl:for-each select="prim:ispartof">
134       <pz:metadata type="journal-subpart">
135         <xsl:value-of select="." />
136       </pz:metadata>
137       <pz:metadata type="citation">
138         <xsl:value-of select="." />
139       </pz:metadata>
140     </xsl:for-each>
141   </xsl:template>
142
143   <xsl:template match="prim:facets">
144     <xsl:for-each select="prim:topic">
145        <pz:metadata type="subject">
146         <xsl:value-of select="." />
147       </pz:metadata>
148     </xsl:for-each>
149   </xsl:template>
150
151   <xsl:template match="sear:LINKS" >
152     <xsl:for-each select="sear:openurl">
153       <pz:metadata type="electronic-url">
154         <xsl:value-of select="."/>
155       </pz:metadata>
156     </xsl:for-each>
157   </xsl:template>
158
159   <xsl:template match="prim:search">
160
161     <xsl:for-each select="prim:creatorcontrib">
162        <pz:metadata type="author">
163         <xsl:value-of select="." />
164       </pz:metadata>
165     </xsl:for-each>
166
167     <xsl:for-each select="prim:description">
168       <pz:metadata type="description">
169         <xsl:value-of select="." />
170       </pz:metadata>
171     </xsl:for-each>
172
173
174     <xsl:for-each select="prim:sub">
175       <pz:metadata type="subject">
176         <xsl:value-of select="." />
177       </pz:metadata>
178     </xsl:for-each>
179
180     <!-- passthrough id data -->
181     <xsl:for-each select="pz:metadata">
182       <xsl:copy-of select="." />
183     </xsl:for-each>
184     <!-- other stylesheets importing this might want to define this -->
185
186     <xsl:call-template name="record-hook" />
187   </xsl:template>
188
189   <xsl:template match="text()" />
190
191 </xsl:stylesheet>