4fe7bc1ac5dc8e236f8acc857b54367d677491c7
[pazpar2-moved-to-github.git] / etc / solr-pz2.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
3                 xmlns:pz="http://www.indexdata.com/pazpar2/1.0" >
4
5   <xsl:param name="medium" />
6
7   <xsl:template  match="/">
8       <xsl:apply-templates></xsl:apply-templates>
9   </xsl:template>
10
11   <xsl:template  match="response">
12       <xsl:apply-templates></xsl:apply-templates>
13   </xsl:template>
14
15   <xsl:template  match="records">
16       <xsl:apply-templates></xsl:apply-templates>
17   </xsl:template>
18
19   <xsl:template match="doc">
20     <pz:record>
21       <xsl:apply-templates></xsl:apply-templates>
22     </pz:record>
23   </xsl:template>
24
25   <xsl:template match="float[@name]">
26     <pz:metadata>
27         <xsl:attribute  name="type">
28           <xsl:value-of select="@name"/>
29         </xsl:attribute>
30         <xsl:value-of select="."/>
31     </pz:metadata>
32   </xsl:template>
33
34   <xsl:template match="str[@name]">
35     <pz:metadata>
36         <xsl:attribute  name="type">
37           <xsl:value-of select="@name"/>
38         </xsl:attribute>
39         <xsl:value-of select="."/>
40     </pz:metadata>
41   </xsl:template>
42
43   <xsl:template match="date[@name]">
44     <pz:metadata>
45         <xsl:attribute  name="type">
46           <xsl:value-of select="@name"/>
47         </xsl:attribute>
48         <xsl:value-of select="."/>
49     </pz:metadata>
50   </xsl:template>
51
52   <xsl:template match="arr">
53     <xsl:for-each select="str">
54       <xsl:call-template name="string"/>
55     </xsl:for-each>
56   </xsl:template>
57
58   <xsl:template name="string">
59       <pz:metadata>
60         <xsl:attribute  name="type">
61           <xsl:value-of select="../@name"/>
62         </xsl:attribute>
63         <xsl:choose>
64           <xsl:when test="../@name = 'medium' and string-length($medium) > 0">
65             <xsl:value-of select="$medium"/>
66           </xsl:when>
67           <xsl:otherwise>
68             <xsl:value-of select="."/>
69           </xsl:otherwise>
70         </xsl:choose>
71       </pz:metadata>
72   </xsl:template>
73
74 </xsl:stylesheet>