b5d2f75a75c169356e870b0a122370ebea54327a
[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="arr">
44     <xsl:for-each select="str">
45       <xsl:call-template name="string"/>
46     </xsl:for-each>
47   </xsl:template>
48
49   <xsl:template name="string">
50       <pz:metadata>
51         <xsl:attribute  name="type">
52           <xsl:value-of select="../@name"/>
53         </xsl:attribute>
54         <xsl:choose>
55           <xsl:when test="../@name = 'medium' and string-length($medium) > 0">
56             <xsl:value-of select="$medium"/>
57           </xsl:when>
58           <xsl:otherwise>
59             <xsl:value-of select="."/>
60           </xsl:otherwise>
61         </xsl:choose>
62       </pz:metadata>
63   </xsl:template>
64
65 </xsl:stylesheet>