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