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