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