4 This stylesheet is used by IRSpy to map the internal mixed Zeerex/IRSpy
5 record format into the Zeerex record which we store.
9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:irspy="http://indexdata.com/irspy/1.0"
11 xmlns="http://explain.z3950.org/dtd/2.0/"
12 xmlns:explain="http://explain.z3950.org/dtd/2.0/"
13 exclude-result-prefixes="irspy explain"
16 <xsl:output indent="yes"
21 <xsl:strip-space elements="*"/>
23 <xsl:variable name="old_indexes" select="/*/explain:indexInfo/explain:index"/>
24 <xsl:variable name="use_attr_names" select="document('use-attr-names.xml')"/>
25 <xsl:variable name="ping_date" select="/*/irspy:status/irspy:probe[last()]"/>
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-configInfo"/>
34 <xsl:call-template name="insert-irspySection"/>
39 <xsl:template name="insert-zeerexBase">
40 <xsl:copy-of select="explain:serverInfo"/>
41 <xsl:copy-of select="explain:databaseInfo"/>
43 <dateModified><xsl:value-of select="$ping_date"/></dateModified>
48 <xsl:template name="insert-indexInfo">
52 <!-- Check that search was actually probed -->
53 <xsl:when test="/*/irspy:status/irspy:search">
54 <xsl:for-each select="/*/irspy:status/irspy:search">
55 <xsl:variable name="set" select="@set"/>
56 <xsl:variable name="ap" select="@ap"/>
57 <xsl:variable name="old"
58 select="$old_indexes[explain:map/explain:attr/@set = $set and
59 explain:map/explain:attr/text() = $ap]"/>
61 <xsl:when test="$old">
62 <xsl:call-template name="insert-index-section">
63 <xsl:with-param name="title" select="$old/explain:title"/>
67 <xsl:call-template name="insert-index-section"/>
73 <!-- If not, insert what we already had... -->
76 select="explain:indexInfo/explain:index[@search='true']"/>
83 <xsl:template name="insert-recordInfo">
87 <!-- Did we actually probe record syntaxes? -->
88 <xsl:when test="/*/irspy:status/irspy:record_fetch">
89 <xsl:for-each select="/*/irspy:status/irspy:record_fetch[@ok = 1]">
90 <recordSyntax name="{@syntax}">
91 <elementSet name="F"/> <!-- FIXME: This should be probed too -->
96 <!-- If not, use the existing test report... -->
98 <xsl:copy-of select="explain:recordInfo/*"/>
105 <xsl:template name="insert-configInfo">
108 <xsl:when test="/*/irspy:status/irspy:init_opt">
109 <xsl:for-each select="/*/irspy:status/irspy:init_opt">
110 <supports type="z3950_{@option}">1</supports>
114 <xsl:copy-of select="explain:configInfo/*"/>
122 Here we list the bits and pieces of the irspy:status element which we
123 want to keep in the persistent version of the zeerex record.
125 <xsl:template name="insert-irspySection">
127 <xsl:copy-of select="*/irspy:libraryType"/>
128 <xsl:copy-of select="*/irspy:country"/>
129 <xsl:copy-of select="*/irspy:probe"/>
131 <xsl:call-template name="insert-latest-nodes">
132 <xsl:with-param name="nodes" select="*/irspy:boolean"/>
133 <xsl:with-param name="what" select="'boolean'"/>
136 <xsl:call-template name="insert-latest-nodes">
137 <xsl:with-param name="nodes" select="*/irspy:named_resultset"/>
138 <xsl:with-param name="what" select="'named_resultset'"/>
141 <xsl:call-template name="insert-latest-nodes">
142 <xsl:with-param name="nodes" select="*/irspy:explain"/>
143 <xsl:with-param name="what" select="'explain'"/>
146 <xsl:call-template name="insert-latest-nodes">
147 <xsl:with-param name="nodes" select="*/irspy:serverImplementationId"/>
148 <xsl:with-param name="what" select="'serverImplementationId'"/>
151 <xsl:call-template name="insert-latest-nodes">
152 <xsl:with-param name="nodes" select="*/irspy:serverImplementationName"/>
153 <xsl:with-param name="what" select="'serverImplementationName'"/>
156 <xsl:call-template name="insert-latest-nodes">
157 <xsl:with-param name="nodes"
158 select="*/irspy:serverImplementationVersion"/>
159 <xsl:with-param name="what" select="'serverImplementationVersion'"/>
162 <xsl:call-template name="insert-latest-nodes">
163 <xsl:with-param name="nodes" select="*/irspy:multiple_opac"/>
164 <xsl:with-param name="what" select="'multiple_opac'"/>
171 NB: This template assumes that the irspy:probe nodes come in ascending
172 order. If this is not the case, this template has to do some kind of
173 sorting which makes the whole thing more complicated.
177 <xsl:template name="insert-latest-nodes">
178 <xsl:param name="nodes"/>
179 <xsl:param name="what" select="'unspecified'"/>
180 <xsl:param name="i" select="count(*/irspy:probe[@ok='1'])"/>
181 <xsl:variable name="date"
182 select="*/irspy:probe[@ok='1'][$i]"/>
183 <xsl:variable name="latest"
184 select="$nodes[irspy:strcmp(text(), $date) >= 0]"/>
187 <xsl:when test="$latest">
188 <xsl:copy-of select="$latest"/>
190 <!-- <xsl:when test="$i > 0 and $i < 200"> -->
191 <xsl:when test="$i > 0">
192 <xsl:call-template name="insert-latest-nodes">
193 <xsl:with-param name="what" select="$what"/>
194 <xsl:with-param name="nodes" select="$nodes"/>
195 <xsl:with-param name="i" select="$i - 1"/>
199 <irspy:missing what="{$what}" when="{$ping_date}"/>
205 <xsl:template match="node() | @*">
207 <xsl:apply-templates select="@* | node()"/>
212 <xsl:template name="insert-index-section">
213 <xsl:param name="update" select="."/>
214 <xsl:param name="title">
215 <xsl:call-template name="insert-index-title">
216 <xsl:with-param name="update" select="$update"/>
220 <xsl:if test="$update/@ok = 1">
221 <index search="true">
222 <title primary="true" lang="en"><xsl:value-of select="$title"/></title>
224 <attr type="1" set="{$update/@set}">
225 <xsl:value-of select="$update/@ap"/>
233 <xsl:template name="insert-index-title">
234 <xsl:param name="update"/>
235 <xsl:variable name="name"
236 select="$use_attr_names/*/map[@attr = $update/@ap and
237 @set = $update/@set]/@name"/>
240 <xsl:when test="string-length($name) > 0"><xsl:value-of
241 select="$name"/></xsl:when>
242 <xsl:otherwise><xsl:value-of select="$update/@ap"/></xsl:otherwise>
247 <xsl:template match="*"/>