+ <!--
+ Here we list the bits and pieces of the irspy:status element which we
+ want to keep in the persistent version of the zeerex record.
+ -->
+ <xsl:template name="insert-irspySection">
+ <irspy:status>
+ <xsl:copy-of select="*/irspy:probe"/>
+
+ <xsl:call-template name="insert-latest-nodes">
+ <xsl:with-param name="nodes" select="*/irspy:boolean"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="insert-latest-nodes">
+ <xsl:with-param name="nodes" select="*/irspy:named_resultset"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="insert-latest-nodes">
+ <xsl:with-param name="nodes" select="*/irspy:explain"/>
+ </xsl:call-template>
+ </irspy:status>
+ </xsl:template>
+
+
+ <!--
+ NB: This template assumes that the irspy:probe nodes come in ascending
+ order. If this is not the case, this template has to do some kind of
+ sorting which makes the whole thing more complicated.
+
+ Dec 12, 2006: Anders
+ -->
+ <xsl:template name="insert-latest-nodes">
+ <xsl:param name="nodes"/>
+ <xsl:param name="i" select="count(*/irspy:probe[@ok='1'])"/>
+ <xsl:variable name="date"
+ select="*/irspy:probe[@ok='1' and position() = $i]"/>
+ <xsl:variable name="latest"
+ select="$nodes[irspy:strcmp(text(), $date) > 0]"/>
+
+ <xsl:choose>
+ <xsl:when test="$latest">
+ <xsl:copy-of select="$latest"/>
+ </xsl:when>
+ <xsl:when test="$i > 0">
+ <xsl:call-template name="insert-latest-nodes">
+ <xsl:with-param name="nodes" select="$nodes"/>
+ <xsl:with-param name="i" select="$i - 1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <irspy:missing/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template match="node() | @*">
+ <xsl:copy>
+ <xsl:apply-templates select="@* | node()"/>
+ </xsl:copy>
+ </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:variable name="name"
+ select="$use_attr_names/*/map[@attr = $update/@ap and
+ @set = $update/@set]/@name"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($name) > 0"><xsl:value-of
+ select="$name"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$update/@ap"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template match="*"/>
+