Add match of score
[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="doc">
12     <pz:record>
13       <xsl:apply-templates></xsl:apply-templates>
14     </pz:record>
15   </xsl:template>
16
17   <xsl:template match="float[@name]">
18     <pz:metadata>
19         <xsl:attribute  name="type">
20           <xsl:value-of select="@name"/>
21         </xsl:attribute>
22         <xsl:value-of select="."/>
23     </pz:metadata>
24   </xsl:template>
25
26   <xsl:template match="str[@name]">
27     <pz:metadata>
28         <xsl:attribute  name="type">
29           <xsl:value-of select="@name"/>
30         </xsl:attribute>
31         <xsl:value-of select="."/>
32     </pz:metadata>
33   </xsl:template>
34
35   <xsl:template match="arr">
36     <xsl:for-each select="str">
37       <xsl:call-template name="string"/>
38     </xsl:for-each>
39   </xsl:template>
40
41   <xsl:template name="string">
42       <pz:metadata>
43         <xsl:attribute  name="type">
44           <xsl:value-of select="../@name"/>
45         </xsl:attribute>
46         <xsl:choose>
47           <xsl:when test="../@name = 'medium' and string-length($medium) > 0">
48             <xsl:value-of select="$medium"/>
49           </xsl:when>
50           <xsl:otherwise>
51             <xsl:value-of select="."/>
52           </xsl:otherwise>
53         </xsl:choose>
54       </pz:metadata>
55   </xsl:template>
56
57 </xsl:stylesheet>