Handle medium override AND md field
[pazpar2-moved-to-github.git] / etc / 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   <!--
20     According to cf/builder/templates/parseTask.cff, connectors can
21     also generate a "medium" field, but that is ignored in this
22     stylesheet, the rule below instead using an XSLT parameter.
23     Should the data element be used in preference when it is included?
24   -->
25
26   <xsl:template match="/record">
27     <pz:record>
28       <pz:metadata type="medium">
29         <xsl:choose>
30           <xsl:when test="string-length($medium)">
31             <xsl:value-of select="$medium" />
32           </xsl:when>
33           <xsl:otherwise>
34             <xsl:if test="medium">
35              <xsl:value-of select="medium" />
36             </xsl:if>
37           </xsl:otherwise>
38         </xsl:choose>
39       </pz:metadata>
40       <xsl:apply-templates/>
41     </pz:record>
42   </xsl:template>
43
44   <!--
45       The elements mapped in the following clauses should be kept more
46       or less in sync with those named in builder/templates/search.cft
47       in the "cf" git module.
48   -->
49
50   <xsl:template match="date">
51     <pz:metadata type="publication-date">
52       <xsl:value-of select="."/>
53     </pz:metadata>
54     <pz:metadata type="date">
55       <xsl:value-of select="."/>
56     </pz:metadata>
57   </xsl:template>
58
59   <xsl:template match="url">
60     <pz:metadata type="electronic-url">
61       <xsl:value-of select="."/>
62     </pz:metadata>
63   </xsl:template>
64
65   <xsl:template match="title">
66     <pz:metadata type="title">
67       <xsl:value-of select="."/>
68     </pz:metadata>
69     <pz:metadata type="title-complete">
70       <xsl:value-of select="." />
71     </pz:metadata>
72   </xsl:template>
73
74   <xsl:template match="journaltitle">
75     <pz:metadata type="journal-title">
76       <xsl:value-of select="."/>
77     </pz:metadata>
78   </xsl:template>
79
80   <!--
81     According to cf/builder/templates/parseTask.cff, connectors can
82     also generate a "holding" field, but it's not clear how that is
83     different from "item".  Perhaps this "item" rule should also
84     handle "holding" in the same way?
85   -->
86
87   <xsl:template match="item">
88     <pz:metadata type="due" empty="PAZPAR2_NULL_VALUE">
89       <xsl:value-of select="due"/>
90     </pz:metadata>
91     <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
92       <xsl:value-of select="location"/>
93     </pz:metadata>
94     <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
95       <xsl:value-of select="callno"/>
96     </pz:metadata>
97     <pz:metadata type="available" empty="PAZPAR_NULL_VALUE">
98       <xsl:value-of select="available"/>
99     </pz:metadata>
100     <pz:metadata type="publicnote" empty="PAZPAR2_NULL_VALUE">
101       <xsl:value-of select="publicnote"/>
102     </pz:metadata>
103   </xsl:template>
104
105   <xsl:template match="location">
106     <pz:metadata type="locallocation">
107       <xsl:value-of select="."/>
108     </pz:metadata>
109   </xsl:template>
110
111   <xsl:template match="callno">
112     <pz:metadata type="callnumber">
113       <xsl:value-of select="."/>
114     </pz:metadata>
115   </xsl:template>
116   
117   <!-- no-op template to avoid printing medium out --> 
118   <xsl:template match="medium" />
119
120   <xsl:template match="*" >
121     <pz:metadata type="{local-name()}">
122       <xsl:value-of select="."/>
123     </pz:metadata>
124   </xsl:template>
125
126   <xsl:template match="text()"/>
127
128 </xsl:stylesheet>