Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/irspy
[irspy-moved-to-github.git] / zebra / zeerex2index.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- See the ZeeRex profile at http://srw.cheshire3.org/profiles/ZeeRex/ -->
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4                 xmlns:z="http://indexdata.dk/zebra/xslt/1"
5                 xmlns:e="http://explain.z3950.org/dtd/2.0/"
6                 xmlns:i="http://indexdata.com/irspy/1.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/@protocol, ':',
17         e:serverInfo/e:host, ':',
18         e:serverInfo/e:port, '/',
19         e:serverInfo/e:database)"/></xsl:variable>
20   <z:record id="{$id}" type="update">
21
22    <!-- Well, not quite _anywhere_.  Only textual fields are indexed -->
23    <z:index name="cql:anywhere" type="w">
24     <xsl:value-of select="e:serverInfo/e:host"/>
25     <xsl:text> </xsl:text>
26     <xsl:value-of select="e:serverInfo/e:port"/>
27     <xsl:text> </xsl:text>
28     <xsl:value-of select="e:serverInfo/e:database"/>
29     <xsl:text> </xsl:text>
30     <xsl:value-of select="e:databaseInfo/e:title"/>
31     <xsl:text> </xsl:text>
32     <xsl:value-of select="e:databaseInfo/e:description"/>
33     <xsl:text> </xsl:text>
34     <xsl:value-of select="e:databaseInfo/e:author"/>
35     <xsl:text> </xsl:text>
36     <xsl:value-of select="e:databaseInfo/i:udb"/>
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="u">
44     <xsl:value-of select="$id"/>
45    </z:index>
46
47    <z:index name="rec:id_raw" type="0">
48     <xsl:value-of select="$id"/>
49    </z:index>
50
51    <!-- serverInfo -->
52    <z:index name="net:protocol" type="w">
53     <xsl:value-of select="e:serverInfo/@protocol"/>
54    </z:index>
55    <z:index name="net:version" type="0">
56     <xsl:value-of select="e:serverInfo/@version"/>
57    </z:index>
58    <z:index name="net:method" type="w">
59     <xsl:value-of select="e:serverInfo/@method"/>
60    </z:index>
61    <z:index name="net:host" type="0">
62     <xsl:value-of select="e:serverInfo/e:host"/>
63    </z:index>
64    <z:index name="net:host" type="s">
65     <xsl:value-of select="e:serverInfo/e:host"/>
66    </z:index>
67    <z:index name="net:port" type="0">
68     <xsl:value-of select="e:serverInfo/e:port"/>
69    </z:index>
70    <z:index name="net:port" type="s">
71     <xsl:value-of select="e:serverInfo/e:port"/>
72    </z:index>
73    <z:index name="net:path" type="0">
74     <xsl:value-of select="e:serverInfo/e:database"/>
75    </z:index>
76    <z:index name="net:path" type="s">
77     <xsl:value-of select="e:serverInfo/e:database"/>
78    </z:index>
79    <z:index name="zeerex:reliability" type="n">
80     <xsl:value-of select="e:serverInfo/e:reliability"/>
81    </z:index>
82    <z:index name="zeerex:reliability" type="s">
83     <xsl:value-of select="e:serverInfo/e:reliability"/>
84    </z:index>
85    <z:index name="dc:date" type="d">
86     <xsl:value-of select="e:serverInfo/e:database/@lastUpdate"/>
87    </z:index>
88    <z:index name="zeerex:numberOfRecords" type="n">
89     <xsl:value-of select="e:serverInfo/e:database/@numRecs"/>
90    </z:index>
91
92    <!-- databaseInfo -->
93    <z:index name="dc:title" type="w">
94     <xsl:value-of select="e:databaseInfo/e:title"/>
95    </z:index>
96    <z:index name="dc:title" type="s">
97     <xsl:value-of select="e:databaseInfo/e:title"/>
98    </z:index>
99    <z:index name="dc:description" type="w">
100     <xsl:value-of select="e:databaseInfo/e:description"/>
101    </z:index>
102    <z:index name="dc:creator" type="w">
103     <xsl:value-of select="e:databaseInfo/e:author"/>
104    </z:index>
105    <z:index name="dc:creator" type="s">
106     <xsl:value-of select="e:databaseInfo/e:author"/>
107    </z:index>
108    <z:index name="dc:language" type="w">
109     <xsl:value-of select="e:databaseInfo/e:langUsage"/>
110    </z:index>
111
112    <!-- metaInfo -->
113    <z:index name="rec:lastModificationDate" type="d">
114     <!-- ### Can Zebra handle this ISO-format date? -->
115     <xsl:value-of select="e:metaInfo/e:dateModified"/>
116    </z:index>
117
118    <!-- indexInfo -->
119    <xsl:for-each select="e:indexInfo/e:index/e:map/e:attr">
120     <z:index name="zeerex:index" type="w">
121      <xsl:value-of select="."/>
122     </z:index>
123    </xsl:for-each>
124
125    <!-- recordInfo -->
126    <z:index name="zeerex:recordSyntax" type="w">
127     <xsl:value-of select="e:recordInfo/e:recordSyntax/@name"/>
128     <!-- ### But @identifier is an OID for Z39.50 -->
129    </z:index>
130
131    <!-- schemaInfo -->
132    <z:index name="zeerex:schema" type="0">
133     <xsl:value-of select="e:schemaInfo/e:schema/@identifier"/>
134     <!-- ### Really?  Identifier? -->
135    </z:index>
136
137    <!-- supportsInfo -->
138    <xsl:for-each select="e:configInfo/e:supports[@type='relationModifier']">
139     <z:index name="zeerex:supports_relationModifier" type="0">
140      <xsl:value-of select="."/>
141     </z:index>
142    </xsl:for-each>
143    <xsl:for-each select="e:configInfo/e:supports[@type='booleanModifier']">
144     <z:index name="zeerex:supports_booleanModifier" type="0">
145      <xsl:value-of select="."/>
146     </z:index>
147    </xsl:for-each>
148    <xsl:for-each select="e:configInfo/e:supports[@type='maskingCharacter']">
149     <z:index name="zeerex:supports_maskingCharacter" type="0">
150      <xsl:value-of select="."/>
151     </z:index>
152    </xsl:for-each>
153    <!-- Many more could be added as required -->
154
155    <!-- extensions -->
156    <z:index name="zeerex:libType" type="0">
157     <xsl:value-of select="i:status/i:libraryType"/>
158    </z:index>
159    <z:index name="zeerex:country" type="0">
160     <xsl:value-of select="i:status/i:country"/>
161    </z:index>
162    <z:index name="zeerex:disabled" type="0">
163     <xsl:value-of select="i:status/i:disabled"/>
164    </z:index>
165    <z:index name="zeerex:udb" type="0">
166     <xsl:value-of select="e:databaseInfo/i:udb"/>
167    </z:index>
168   </z:record>
169  </xsl:template>
170 </xsl:stylesheet>