index zeerex2index.xsl as words
[irspy-moved-to-github.git] / zebra / zeerex2index.xsl
index d65bd6a..b153968 100644 (file)
@@ -1,32 +1,45 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id: zeerex2index.xsl,v 1.6 2006-10-06 11:07:11 mike Exp $ -->
 <!-- See the ZeeRex profile at http://srw.cheshire3.org/profiles/ZeeRex/ -->
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:z="http://indexdata.dk/zebra/xslt/1"
                 xmlns:e="http://explain.z3950.org/dtd/2.0/"
+                xmlns:i="http://indexdata.com/irspy/1.0"
                 version="1.0">
+ <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
+ <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
  <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
  <!-- Disable all default text node output -->
  <xsl:template match="text()"/>
  <!-- Match on ZeeRex XML record -->
  <xsl:template match="//e:explain">
-  <z:record id="{concat(
-               e:serverInfo/e:host, ':',
-               e:serverInfo/e:port, '/',
-               e:serverInfo/e:database)}"
-           type="update">
+  <xsl:variable name="id"><xsl:value-of select="concat(
+       e:serverInfo/@protocol, ':',
+       e:serverInfo/e:host, ':',
+       e:serverInfo/e:port, '/',
+       e:serverInfo/e:database)"/></xsl:variable>
+  <z:record id="{$id}" type="update">
 
-   <!-- ### define "cql:anywhere" -->
+   <!-- Well, not quite _anywhere_.  Only textual fields are indexed -->
+   <z:index name="cql:anywhere" type="w">
+    <xsl:value-of select="e:serverInfo/e:host"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="e:serverInfo/e:port"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="e:serverInfo/e:database"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="e:databaseInfo/e:title"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="e:databaseInfo/e:description"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="e:databaseInfo/e:author"/>
+   </z:index>
 
    <z:index name="rec:authorityIndicator" type="0">
     <xsl:value-of select="@authoritative"/>
    </z:index>
 
-   <z:index name="rec:id" type="0">
-    <xsl:value-of select="concat(
-                         e:serverInfo/e:host, ':',
-                         e:serverInfo/e:port, '/',
-                         e:serverInfo/e:database)"/>
+   <z:index name="rec:id" type="u">
+    <xsl:value-of select="$id"/>
    </z:index>
 
    <!-- serverInfo -->
@@ -57,6 +70,9 @@
    <z:index name="net:path" type="s">
     <xsl:value-of select="e:serverInfo/e:database"/>
    </z:index>
+   <z:index name="zeerex:reliability" type="n">
+    <xsl:value-of select="e:serverInfo/e:reliability"/>
+   </z:index>
    <z:index name="dc:date" type="d">
     <xsl:value-of select="e:serverInfo/e:database/@lastUpdate"/>
    </z:index>
     <xsl:value-of select="e:metaInfo/e:dateModified"/>
    </z:index>
 
-   <!-- ### indexInfo -->
+   <!-- indexInfo -->
+   <xsl:for-each select="e:indexInfo/e:index/e:map/e:attr">
+    <z:index name="zeerex:index" type="w">
+     <xsl:value-of select="."/>
+    </z:index>
+   </xsl:for-each>
 
    <!-- recordInfo -->
-   <z:index name="zeerex:recordSyntax" type="0">
-    <xsl:value-of select="e:recordInfo/e:recordSyntax/@identifier"/>
+   <z:index name="zeerex:recordSyntax" type="w">
+    <xsl:value-of select="e:recordInfo/e:recordSyntax/@name"/>
     <!-- ### But @identifier is an OID for Z39.50 -->
    </z:index>
 
    </xsl:for-each>
    <!-- Many more could be added as required -->
 
+   <!-- extensions -->
+   <z:index name="zeerex:libType" type="0">
+    <xsl:value-of select="i:status/i:libraryType"/>
+   </z:index>
+   <z:index name="zeerex:country" type="0">
+    <xsl:value-of select="i:status/i:country"/>
+   </z:index>
+
   </z:record>
  </xsl:template>
 </xsl:stylesheet>