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