3 $Id: irspy2zeerex.xsl,v 1.11 2006-11-02 11:46:41 sondberg Exp $
5 This stylesheet is used by IRSpy to map the internal mixed Zeerex/IRSpy
6 record format into the Zeerex record which we store.
10 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 xmlns:irspy="http://indexdata.com/irspy/1.0"
12 xmlns="http://explain.z3950.org/dtd/2.0/"
13 xmlns:explain="http://explain.z3950.org/dtd/2.0/"
14 exclude-result-prefixes="irspy explain"
17 <xsl:output indent="yes"
22 <xsl:strip-space elements="*"/>
24 <xsl:variable name="old_indexes" select="/*/explain:indexInfo/explain:index"/>
25 <xsl:variable name="use_attr_names" select="document('use-attr-names.xml')"/>
28 <xsl:template match="/*">
30 <xsl:call-template name="insert-zeerexBase"/>
31 <xsl:call-template name="insert-indexInfo"/>
32 <xsl:call-template name="insert-recordInfo"/>
33 <xsl:call-template name="insert-irspySection"/>
38 <xsl:template name="insert-zeerexBase">
39 <xsl:copy-of select="explain:serverInfo"/>
40 <xsl:copy-of select="explain:databaseInfo"/>
42 <dateModified><xsl:value-of
43 select="/*/irspy:status/*[last()]"/></dateModified>
48 <xsl:template name="insert-indexInfo">
50 <xsl:for-each select="/*/irspy:status/irspy:search">
51 <xsl:variable name="set" select="@set"/>
52 <xsl:variable name="ap" select="@ap"/>
53 <xsl:variable name="old"
54 select="$old_indexes[explain:map/explain:attr/@set = $set and
55 explain:map/explain:attr/text() = $ap]"/>
57 <xsl:when test="$old">
58 <xsl:call-template name="insert-index-section">
59 <xsl:with-param name="title" select="$old/explain:title"/>
63 <xsl:call-template name="insert-index-section"/>
71 <xsl:template name="insert-recordInfo">
73 <xsl:for-each select="/*/irspy:status/irspy:record_fetch[@ok = 1]">
74 <recordSyntax name="{@syntax}">
75 <elementSet name="F"/> <!-- FIXME: This should be probed too -->
83 Here we list the bits and pieces of the irspy:status element which we
84 want to keep in the persistent version of the zeerex record.
85 Simply add "| irspy:xxx" to the select attribute.
87 <xsl:template name="insert-irspySection">
89 <xsl:for-each select="*/irspy:probe |
91 */irspy:named_resultset |
93 <xsl:copy-of select="."/>
99 <xsl:template match="node() | @*">
101 <xsl:apply-templates select="@* | node()"/>
106 <xsl:template name="insert-index-section">
107 <xsl:param name="update" select="."/>
108 <xsl:param name="title">
109 <xsl:call-template name="insert-index-title">
110 <xsl:with-param name="update" select="$update"/>
115 <xsl:attribute name="search">
117 <xsl:when test="$update/@ok = 1">true</xsl:when>
118 <xsl:otherwise>false</xsl:otherwise>
121 <title primary="true" lang="en">
122 <xsl:value-of select="$title"/>
125 <attr type="1" set="{$update/@set}">
126 <xsl:value-of select="$update/@ap"/>
133 <xsl:template name="insert-index-title">
134 <xsl:param name="update"/>
135 <xsl:variable name="name"
136 select="$use_attr_names/*/map[@attr = $update/@ap and
137 @set = $update/@set]/@name"/>
140 <xsl:when test="string-length($name) > 0"><xsl:value-of
141 select="$name"/></xsl:when>
142 <xsl:otherwise><xsl:value-of select="$update/@ap"/></xsl:otherwise>
147 <xsl:template match="*"/>