43a92a124d80a448fb51bf7fd8be9133fbb543b4
[pazpar2-moved-to-github.git] / etc / 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     <xsl:for-each select="prim:creator">
109        <pz:metadata type="author">
110         <xsl:value-of select="." />
111       </pz:metadata>
112     </xsl:for-each>  
113     <xsl:for-each select="prim:type">
114       <xsl:variable name="type" select="."/>
115       <pz:metadata type="medium">
116         <xsl:choose>
117           <xsl:when test="$type ='article' and $has_fulltext = 'yes'">
118             <xsl:text>e-article</xsl:text>
119           </xsl:when>
120           <xsl:when  test="$type = 'article' and $has_fulltext = 'no'">
121             <xsl:text>article</xsl:text>
122           </xsl:when>
123           <xsl:otherwise>
124             <xsl:value-of select="$type"/>
125           </xsl:otherwise>
126         </xsl:choose>
127 <!--        <xsl:value-of select="$type" /> -->
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     </xsl:for-each>
143 <!--
144     <xsl:apply-templates />
145 -->
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     <xsl:for-each select="prim:description">
166       <pz:metadata type="description">
167         <xsl:value-of select="." />
168       </pz:metadata>
169     </xsl:for-each>
170
171
172     <xsl:for-each select="prim:sub">
173       <pz:metadata type="subject">
174         <xsl:value-of select="." />
175       </pz:metadata>
176     </xsl:for-each>
177
178     <!-- passthrough id data -->
179     <xsl:for-each select="pz:metadata">
180       <xsl:copy-of select="." />
181     </xsl:for-each>
182     <!-- other stylesheets importing this might want to define this -->
183
184     <xsl:call-template name="record-hook" />    
185   </xsl:template>
186
187   <xsl:template match="text()" />
188
189 </xsl:stylesheet>