Another attempt at figuring out what's upsetting tidy.
[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    </z:index>
36
37    <z:index name="rec:authorityIndicator" type="0">
38     <xsl:value-of select="@authoritative"/>
39    </z:index>
40
41    <z:index name="rec:id" type="u">
42     <xsl:value-of select="$id"/>
43    </z:index>
44
45    <z:index name="rec:id_raw" type="0">
46     <xsl:value-of select="$id"/>
47    </z:index>
48
49    <!-- serverInfo -->
50    <z:index name="net:protocol" type="w">
51     <xsl:value-of select="e:serverInfo/@protocol"/>
52    </z:index>
53    <z:index name="net:version" type="0">
54     <xsl:value-of select="e:serverInfo/@version"/>
55    </z:index>
56    <z:index name="net:method" type="w">
57     <xsl:value-of select="e:serverInfo/@method"/>
58    </z:index>
59    <z:index name="net:host" type="0">
60     <xsl:value-of select="e:serverInfo/e:host"/>
61    </z:index>
62    <z:index name="net:host" type="s">
63     <xsl:value-of select="e:serverInfo/e:host"/>
64    </z:index>
65    <z:index name="net:port" type="0">
66     <xsl:value-of select="e:serverInfo/e:port"/>
67    </z:index>
68    <z:index name="net:port" type="s">
69     <xsl:value-of select="e:serverInfo/e:port"/>
70    </z:index>
71    <z:index name="net:path" type="0">
72     <xsl:value-of select="e:serverInfo/e:database"/>
73    </z:index>
74    <z:index name="net:path" type="s">
75     <xsl:value-of select="e:serverInfo/e:database"/>
76    </z:index>
77    <z:index name="zeerex:reliability" type="n">
78     <xsl:value-of select="e:serverInfo/e:reliability"/>
79    </z:index>
80    <z:index name="zeerex:reliability" type="s">
81     <xsl:value-of select="e:serverInfo/e:reliability"/>
82    </z:index>
83    <z:index name="dc:date" type="d">
84     <xsl:value-of select="e:serverInfo/e:database/@lastUpdate"/>
85    </z:index>
86    <z:index name="zeerex:numberOfRecords" type="n">
87     <xsl:value-of select="e:serverInfo/e:database/@numRecs"/>
88    </z:index>
89
90    <!-- databaseInfo -->
91    <z:index name="dc:title" type="w">
92     <xsl:value-of select="e:databaseInfo/e:title"/>
93    </z:index>
94    <z:index name="dc:title" type="s">
95     <xsl:value-of select="e:databaseInfo/e:title"/>
96    </z:index>
97    <z:index name="dc:description" type="w">
98     <xsl:value-of select="e:databaseInfo/e:description"/>
99    </z:index>
100    <z:index name="dc:creator" type="w">
101     <xsl:value-of select="e:databaseInfo/e:author"/>
102    </z:index>
103    <z:index name="dc:creator" type="s">
104     <xsl:value-of select="e:databaseInfo/e:author"/>
105    </z:index>
106    <z:index name="dc:language" type="w">
107     <xsl:value-of select="e:databaseInfo/e:langUsage"/>
108    </z:index>
109
110    <!-- metaInfo -->
111    <z:index name="rec:lastModificationDate" type="d">
112     <!-- ### Can Zebra handle this ISO-format date? -->
113     <xsl:value-of select="e:metaInfo/e:dateModified"/>
114    </z:index>
115
116    <!-- indexInfo -->
117    <xsl:for-each select="e:indexInfo/e:index/e:map/e:attr">
118     <z:index name="zeerex:index" type="w">
119      <xsl:value-of select="."/>
120     </z:index>
121    </xsl:for-each>
122
123    <!-- recordInfo -->
124    <z:index name="zeerex:recordSyntax" type="w">
125     <xsl:value-of select="e:recordInfo/e:recordSyntax/@name"/>
126     <!-- ### But @identifier is an OID for Z39.50 -->
127    </z:index>
128
129    <!-- schemaInfo -->
130    <z:index name="zeerex:schema" type="0">
131     <xsl:value-of select="e:schemaInfo/e:schema/@identifier"/>
132     <!-- ### Really?  Identifier? -->
133    </z:index>
134
135    <!-- supportsInfo -->
136    <xsl:for-each select="e:configInfo/e:supports[@type='relationModifier']">
137     <z:index name="zeerex:supports_relationModifier" type="0">
138      <xsl:value-of select="."/>
139     </z:index>
140    </xsl:for-each>
141    <xsl:for-each select="e:configInfo/e:supports[@type='booleanModifier']">
142     <z:index name="zeerex:supports_booleanModifier" type="0">
143      <xsl:value-of select="."/>
144     </z:index>
145    </xsl:for-each>
146    <xsl:for-each select="e:configInfo/e:supports[@type='maskingCharacter']">
147     <z:index name="zeerex:supports_maskingCharacter" type="0">
148      <xsl:value-of select="."/>
149     </z:index>
150    </xsl:for-each>
151    <!-- Many more could be added as required -->
152
153    <!-- extensions -->
154    <z:index name="zeerex:libType" type="0">
155     <xsl:value-of select="i:status/i:libraryType"/>
156    </z:index>
157    <z:index name="zeerex:country" type="0">
158     <xsl:value-of select="i:status/i:country"/>
159    </z:index>
160    <z:index name="zeerex:disabled" type="0">
161     <xsl:value-of select="i:status/i:disabled"/>
162    </z:index>
163
164   </z:record>
165  </xsl:template>
166 </xsl:stylesheet>