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