indexInfo is now updated with information from the irspy:status section.
authorAnders S. Mortensen <sondberg@indexdata.dk>
Fri, 27 Oct 2006 11:43:17 +0000 (11:43 +0000)
committerAnders S. Mortensen <sondberg@indexdata.dk>
Fri, 27 Oct 2006 11:43:17 +0000 (11:43 +0000)
xsl/irspy2zeerex.xsl

index f579a91..95946db 100644 (file)
@@ -1,6 +1,17 @@
 <?xml version="1.0"?>
-<!-- $Id: irspy2zeerex.xsl,v 1.1 2006-10-26 13:39:13 sondberg Exp $ -->
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+<!--
+    $Id: irspy2zeerex.xsl,v 1.2 2006-10-27 11:43:17 sondberg Exp $
+
+    This stylesheet is used by IRSpy to map the internal mixed Zeerex/IRSpy
+    record format into the Zeerex record which we store.
+
+-->
+<xsl:stylesheet
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:irspy="http://indexdata.com/irspy/1.0"
+    xmlns="http://explain.z3950.org/dtd/2.0/"
+    xmlns:explain="http://explain.z3950.org/dtd/2.0/"
+    exclude-result-prefixes="irspy explain"
     version="1.0">
 
   <xsl:output indent="yes"
@@ -8,9 +19,83 @@
       version="1.0"
       encoding="UTF-8"/>
 
-  <!-- identity stylesheet -->
-  <xsl:template match="/">
-    <xsl:copy-of select="/"/>
+  <xsl:preserve-space elements="*"/>
+
+  <xsl:variable name="old_indexes" select="/*/explain:indexInfo/explain:index"/>
+  <xsl:variable name="old_syntaxes" select="/*/explain:recordInfo"/>
+
+
+  <xsl:template match="node() | @*">
+    <xsl:copy>
+      <xsl:apply-templates select="@* | node()"/>
+    </xsl:copy>
+  </xsl:template>
+
+
+  <xsl:template match="explain:indexInfo">
+    <indexInfo>
+      <xsl:for-each select="/*/irspy:status/irspy:search">
+        <xsl:variable name="set" select="@set"/>
+        <xsl:variable name="ap" select="@ap"/>
+        <xsl:variable name="old"
+         select="$old_indexes[explain:map/explain:attr/@set = $set and
+                              explain:map/explain:attr/text() = $ap]"/>
+        <xsl:choose>
+          <xsl:when test="$old">
+            <xsl:call-template name="insert-index-section">
+              <xsl:with-param name="title" select="$old/explain:title"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:call-template name="insert-index-section"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </indexInfo>
+  </xsl:template>
+
+
+  <xsl:template match="explain:recordInfo">
+  </xsl:template>
+
+
+  <xsl:template name="insert-index-section">
+    <xsl:param name="update" select="."/>
+    <xsl:param name="title">
+      <xsl:call-template name="insert-index-title">
+        <xsl:with-param name="update" select="$update"/>
+      </xsl:call-template>
+    </xsl:param>
+
+    <index>
+      <xsl:attribute name="search">
+        <xsl:choose>
+          <xsl:when test="$update/@ok = 1">true</xsl:when>
+          <xsl:otherwise>false</xsl:otherwise>
+        </xsl:choose>
+      </xsl:attribute>
+      <title primary="true" lang="en">
+        <xsl:value-of select="$title"/>
+      </title>
+      <map primary="true">
+        <attr type="1" set="{$update/@set}">
+          <xsl:value-of select="$update/@ap"/>
+        </attr>
+      </map>
+    </index>
+  </xsl:template>
+
+
+  <xsl:template name="insert-index-title">
+    <xsl:param name="update"/>
+    <xsl:value-of select="$update/@ap"/>
+  </xsl:template>
+
+
+
+  <xsl:template match="explain:dateModified">
+    <dateModified><xsl:value-of
+                    select="/*/irspy:status/*[last()]"/></dateModified>
   </xsl:template>