Define cql:anywhere
[irspy-moved-to-github.git] / zebra / zeerex2index.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Id: zeerex2index.xsl,v 1.7 2006-11-30 12:44:00 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 ZeeRex 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    <!-- Well, not quite _anywhere_.  Only textual fields are indexed -->
20    <z:index name="cql:anywhere" type="w">
21     <xsl:value-of select="e:serverInfo/e:host"/>
22    </z:index>
23    <z:index name="cql:anywhere" type="w">
24     <xsl:value-of select="e:serverInfo/e:port"/>
25    </z:index>
26    <z:index name="cql:anywhere" type="w">
27     <xsl:value-of select="e:serverInfo/e:database"/>
28    </z:index>
29    <z:index name="cql:anywhere" type="w">
30     <xsl:value-of select="e:databaseInfo/e:title"/>
31    </z:index>
32    <z:index name="cql:anywhere" type="w">
33     <xsl:value-of select="e:databaseInfo/e:description"/>
34    </z:index>
35    <z:index name="cql:anywhere" type="w">
36     <xsl:value-of select="e:databaseInfo/e:author"/>
37    </z:index>
38
39    <z:index name="rec:authorityIndicator" type="0">
40     <xsl:value-of select="@authoritative"/>
41    </z:index>
42
43    <z:index name="rec:id" type="0">
44     <xsl:value-of select="concat(
45                           e:serverInfo/e:host, ':',
46                           e:serverInfo/e:port, '/',
47                           e:serverInfo/e:database)"/>
48    </z:index>
49
50    <!-- serverInfo -->
51    <z:index name="net:protocol" type="w">
52     <xsl:value-of select="e:serverInfo/@protocol"/>
53    </z:index>
54    <z:index name="net:version" type="0">
55     <xsl:value-of select="e:serverInfo/@version"/>
56    </z:index>
57    <z:index name="net:method" type="w">
58     <xsl:value-of select="e:serverInfo/@method"/>
59    </z:index>
60    <z:index name="net:host" type="0">
61     <xsl:value-of select="e:serverInfo/e:host"/>
62    </z:index>
63    <z:index name="net:host" type="s">
64     <xsl:value-of select="e:serverInfo/e:host"/>
65    </z:index>
66    <z:index name="net:port" type="0">
67     <xsl:value-of select="e:serverInfo/e:port"/>
68    </z:index>
69    <z:index name="net:port" type="s">
70     <xsl:value-of select="e:serverInfo/e:port"/>
71    </z:index>
72    <z:index name="net:path" type="0">
73     <xsl:value-of select="e:serverInfo/e:database"/>
74    </z:index>
75    <z:index name="net:path" type="s">
76     <xsl:value-of select="e:serverInfo/e:database"/>
77    </z:index>
78    <z:index name="dc:date" type="d">
79     <xsl:value-of select="e:serverInfo/e:database/@lastUpdate"/>
80    </z:index>
81    <z:index name="zeerex:numberOfRecords" type="n">
82     <xsl:value-of select="e:serverInfo/e:database/@numRecs"/>
83    </z:index>
84
85    <!-- databaseInfo -->
86    <z:index name="dc:title" type="w">
87     <xsl:value-of select="e:databaseInfo/e:title"/>
88    </z:index>
89    <z:index name="dc:title" type="s">
90     <xsl:value-of select="e:databaseInfo/e:title"/>
91    </z:index>
92    <z:index name="dc:description" type="w">
93     <xsl:value-of select="e:databaseInfo/e:description"/>
94    </z:index>
95    <z:index name="dc:creator" type="w">
96     <xsl:value-of select="e:databaseInfo/e:author"/>
97    </z:index>
98    <z:index name="dc:creator" type="s">
99     <xsl:value-of select="e:databaseInfo/e:author"/>
100    </z:index>
101    <z:index name="dc:language" type="w">
102     <xsl:value-of select="e:databaseInfo/e:langUsage"/>
103    </z:index>
104
105    <!-- metaInfo -->
106    <z:index name="rec:lastModificationDate" type="d">
107     <!-- ### Can Zebra handle this ISO-format date? -->
108     <xsl:value-of select="e:metaInfo/e:dateModified"/>
109    </z:index>
110
111    <!-- ### indexInfo -->
112
113    <!-- recordInfo -->
114    <z:index name="zeerex:recordSyntax" type="0">
115     <xsl:value-of select="e:recordInfo/e:recordSyntax/@identifier"/>
116     <!-- ### But @identifier is an OID for Z39.50 -->
117    </z:index>
118
119    <!-- schemaInfo -->
120    <z:index name="zeerex:schema" type="0">
121     <xsl:value-of select="e:schemaInfo/e:schema/@identifier"/>
122     <!-- ### Really?  Identifier? -->
123    </z:index>
124
125    <!-- supportsInfo -->
126    <xsl:for-each select="e:configInfo/e:supports[@type='relationModifier']">
127     <z:index name="zeerex:supports_relationModifier" type="0">
128      <xsl:value-of select="."/>
129     </z:index>
130    </xsl:for-each>
131    <xsl:for-each select="e:configInfo/e:supports[@type='booleanModifier']">
132     <z:index name="zeerex:supports_booleanModifier" type="0">
133      <xsl:value-of select="."/>
134     </z:index>
135    </xsl:for-each>
136    <xsl:for-each select="e:configInfo/e:supports[@type='maskingCharacter']">
137     <z:index name="zeerex:supports_maskingCharacter" type="0">
138      <xsl:value-of select="."/>
139     </z:index>
140    </xsl:for-each>
141    <!-- Many more could be added as required -->
142
143   </z:record>
144  </xsl:template>
145 </xsl:stylesheet>