5f0c4ea10183a09bacba6b0ca6b99d09305d77b5
[pazpar2-moved-to-github.git] / etc / xsl / cf.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3     This stylesheet expects Connector Frameworks records
4 -->
5 <xsl:stylesheet
6     version="1.0"
7     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8     xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
9     xmlns:dc="http://purl.org/dc/elements/1.1/"
10     xmlns:siebel="http://loc.gov/siebel/elements/1.0/" >
11
12  <xsl:output indent="yes"
13         method="xml"
14         version="1.0"
15         encoding="UTF-8"/>
16
17   <xsl:param name="medium" />
18
19   <!-- Use medium parameter if given. Default to medium from connector -->
20   <xsl:template match="/record">
21     <pz:record>
22       <pz:metadata type="medium">
23         <xsl:choose>
24           <xsl:when test="string-length($medium)">
25             <xsl:value-of select="$medium" />
26           </xsl:when>
27           <xsl:otherwise>
28             <xsl:if test="medium">
29              <xsl:value-of select="medium" />
30             </xsl:if>
31           </xsl:otherwise>
32         </xsl:choose>
33       </pz:metadata>
34       <xsl:apply-templates/>
35     </pz:record>
36   </xsl:template>
37
38   <!--
39       The elements mapped in the following clauses should be kept more
40       or less in sync with those named in builder/templates/search.cft
41       in the "cf" git module.
42   -->
43
44   <xsl:template match="date">
45     <pz:metadata type="publication-date">
46       <xsl:value-of select="."/>
47     </pz:metadata>
48     <pz:metadata type="date">
49       <xsl:value-of select="."/>
50     </pz:metadata>
51   </xsl:template>
52
53   <xsl:template match="url">
54     <pz:metadata type="electronic-url">
55       <xsl:value-of select="."/>
56     </pz:metadata>
57   </xsl:template>
58
59   <xsl:template match="title">
60     <pz:metadata type="title">
61       <xsl:value-of select="."/>
62     </pz:metadata>
63     <pz:metadata type="title-complete">
64       <xsl:value-of select="." />
65     </pz:metadata>
66   </xsl:template>
67
68   <xsl:template match="journaltitle">
69     <pz:metadata type="journal-title">
70       <xsl:value-of select="."/>
71     </pz:metadata>
72   </xsl:template>
73
74   <!--
75     According to cf/builder/templates/parseTask.cff, connectors can
76     also generate a "holding" field, but it's not clear how that is
77     different from "item".  Perhaps this "item" rule should also
78     handle "holding" in the same way?
79   -->
80
81   <xsl:template match="item">
82     <pz:metadata type="due" empty="PAZPAR2_NULL_VALUE">
83       <xsl:value-of select="due"/>
84     </pz:metadata>
85     <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
86       <xsl:value-of select="location"/>
87     </pz:metadata>
88     <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
89       <xsl:value-of select="callno"/>
90     </pz:metadata>
91     <pz:metadata type="available" empty="PAZPAR_NULL_VALUE">
92       <xsl:value-of select="available"/>
93     </pz:metadata>
94     <pz:metadata type="publicnote" empty="PAZPAR2_NULL_VALUE">
95       <xsl:value-of select="publicnote"/>
96     </pz:metadata>
97   </xsl:template>
98
99   <xsl:template match="location">
100     <pz:metadata type="locallocation">
101       <xsl:value-of select="."/>
102     </pz:metadata>
103   </xsl:template>
104
105   <xsl:template match="callno">
106     <pz:metadata type="callnumber">
107       <xsl:value-of select="."/>
108     </pz:metadata>
109   </xsl:template>
110
111   <!-- no-op template to avoid printing medium out -->
112   <xsl:template match="medium" />
113
114   <xsl:template match="volume">
115     <pz:metadata type="volume-number">
116       <xsl:value-of select="."/>
117     </pz:metadata>
118   </xsl:template>
119
120   <xsl:template match="issue">
121     <pz:metadata type="issue-number">
122       <xsl:value-of select="."/>
123     </pz:metadata>
124   </xsl:template>
125
126   <!-- put both page and pages-number for page -->
127   <xsl:template match="page">
128     <pz:metadata type="pages-number">
129       <xsl:value-of select="."/>
130     </pz:metadata>
131     <pz:metadata type="page">
132       <xsl:value-of select="."/>
133     </pz:metadata>
134   </xsl:template>
135   <!-- leave endpage as is -->
136
137   <xsl:template match="*" >
138     <pz:metadata type="{local-name()}">
139       <xsl:value-of select="."/>
140     </pz:metadata>
141   </xsl:template>
142
143   <xsl:template match="text()"/>
144
145 </xsl:stylesheet>