Add indexes to support sorting on
[irspy-moved-to-github.git] / zebra / zeerex2index.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Id: zeerex2index.xsl,v 1.4 2006-09-19 16:24:59 mike Exp $ -->
3 <!-- See the ZeeRex profile at http://srw.cheshire3.org/profiles/ZeeRex/ -->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5                 xmlns:z="http://indexdata.dk/zebra/xslt/1"
6                 xmlns:e="http://explain.z3950.org/dtd/2.0/"
7                 version="1.0">
8  <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
9  <!-- disable all default text node output -->
10  <xsl:template match="text()"/>
11  <!-- match on alvis xml record -->
12  <xsl:template match="//e:explain">
13   <z:record id="{concat(
14                 e:serverInfo/e:host, ':',
15                 e:serverInfo/e:port, '/',
16                 e:serverInfo/e:database)}"
17             type="update">
18
19    <!-- ### define "cql:anywhere" -->
20
21    <z:index name="rec:authorityIndicator" type="0">
22     <xsl:value-of select="@authoritative"/>
23    </z:index>
24
25    <z:index name="rec:id" type="0">
26     <xsl:value-of select="concat(
27                           e:serverInfo/e:host, ':',
28                           e:serverInfo/e:port, '/',
29                           e:serverInfo/e:database)"/>
30    </z:index>
31
32    <!-- serverInfo -->
33    <z:index name="net:protocol" type="w">
34     <xsl:value-of select="e:serverInfo/@protocol"/>
35    </z:index>
36    <z:index name="net:version" type="0">
37     <xsl:value-of select="e:serverInfo/@version"/>
38    </z:index>
39    <z:index name="net:method" type="w">
40     <xsl:value-of select="e:serverInfo/@method"/>
41    </z:index>
42    <z:index name="net:host" type="0">
43     <xsl:value-of select="e:serverInfo/e:host"/>
44    </z:index>
45    <z:index name="net:host" type="s">
46     <xsl:value-of select="e:serverInfo/e:host"/>
47    </z:index>
48    <z:index name="net:port" type="0">
49     <xsl:value-of select="e:serverInfo/e:port"/>
50    </z:index>
51    <z:index name="net:port" type="s">
52     <xsl:value-of select="e:serverInfo/e:port"/>
53    </z:index>
54    <z:index name="net:path" type="w"><!-- "w" for case-insensitivity -->
55     <xsl:value-of select="e:serverInfo/e:database"/>
56    </z:index>
57    <z:index name="net:path" type="s">
58     <xsl:value-of select="e:serverInfo/e:database"/>
59    </z:index>
60    <z:index name="dc:date" type="d">
61     <xsl:value-of select="e:serverInfo/e:database/@lastUpdate"/>
62    </z:index>
63    <z:index name="zeerex:numberOfRecords" type="n">
64     <xsl:value-of select="e:serverInfo/e:database/@numRecs"/>
65    </z:index>
66
67    <!-- databaseInfo -->
68    <z:index name="dc:title" type="w">
69     <xsl:value-of select="e:databaseInfo/e:title"/>
70    </z:index>
71    <z:index name="dc:title" type="s">
72     <xsl:value-of select="e:databaseInfo/e:title"/>
73    </z:index>
74    <z:index name="dc:description" type="w">
75     <xsl:value-of select="e:databaseInfo/e:description"/>
76    </z:index>
77    <z:index name="dc:creator" type="w">
78     <xsl:value-of select="e:databaseInfo/e:author"/>
79    </z:index>
80    <z:index name="dc:creator" type="s">
81     <xsl:value-of select="e:databaseInfo/e:author"/>
82    </z:index>
83    <z:index name="dc:language" type="w">
84     <xsl:value-of select="e:databaseInfo/e:langUsage"/>
85    </z:index>
86
87    <!-- metaInfo -->
88    <z:index name="rec:lastModificationDate" type="d">
89     <!-- ### Can Zebra handle this ISO-format date? -->
90     <xsl:value-of select="e:metaInfo/e:dateModified"/>
91    </z:index>
92
93    <!-- ### indexInfo -->
94
95    <!-- recordInfo -->
96    <z:index name="zeerex:recordSyntax" type="0">
97     <xsl:value-of select="e:recordInfo/e:recordSyntax/@identifier"/>
98     <!-- ### But @identifier is an OID for Z39.50 -->
99    </z:index>
100
101    <!-- schemaInfo -->
102    <z:index name="zeerex:schema" type="0">
103     <xsl:value-of select="e:schemaInfo/e:schema/@identifier"/>
104     <!-- ### Really?  Identifier? -->
105    </z:index>
106
107    <!-- supportsInfo -->
108    <xsl:for-each select="e:configInfo/e:supports[@type='relationModifier']">
109     <z:index name="zeerex:supports_relationModifier" type="0">
110      <xsl:value-of select="."/>
111     </z:index>
112    </xsl:for-each>
113    <xsl:for-each select="e:configInfo/e:supports[@type='booleanModifier']">
114     <z:index name="zeerex:supports_booleanModifier" type="0">
115      <xsl:value-of select="."/>
116     </z:index>
117    </xsl:for-each>
118    <xsl:for-each select="e:configInfo/e:supports[@type='maskingCharacter']">
119     <z:index name="zeerex:supports_maskingCharacter" type="0">
120      <xsl:value-of select="."/>
121     </z:index>
122    </xsl:for-each>
123    <!-- Many more could be added as required -->
124
125   </z:record>
126  </xsl:template>
127 </xsl:stylesheet>