-# $Id: IRSpy.pm,v 1.52 2006-12-06 11:26:52 mike Exp $
+# $Id: IRSpy.pm,v 1.53 2006-12-11 13:58:17 sondberg Exp $
package ZOOM::IRSpy;
or die "$0: can't connection to IRSpy database 'dbname'";
my $xslt = new XML::LibXSLT;
+
+ $xslt->register_function($ZOOM::IRSpy::Utils::IRSPY_NS, 'strcmp',
+ \&ZOOM::IRSpy::Utils::xslt_strcmp);
+
my $libxml = new XML::LibXML;
my $xsl_doc = $libxml->parse_file($irspy_to_zeerex_xsl);
my $irspy_to_zeerex_style = $xslt->parse_stylesheet($xsl_doc);
sub _irspy_to_zeerex {
my ($this, $conn) = @_;
my $irspy_doc = $conn->record()->{zeerex}->ownerDocument;
+ #open FH, '>/tmp/irspy_orig.xml';
+ #print FH $irspy_doc->toString();
+ #close FH;
my %params = ();
my $result = $this->{irspy_to_zeerex_style}->transform($irspy_doc, %params);
+ #open FH, '>/tmp/irspy_transformed.xml';
+ #print FH $result->toString();
+ #close FH;
+
return $result->documentElement();
}
-# $Id: Utils.pm,v 1.19 2006-12-05 17:19:35 mike Exp $
+# $Id: Utils.pm,v 1.20 2006-12-11 13:58:17 sondberg Exp $
package ZOOM::IRSpy::Utils;
}
-#print "Loaded ZOOM::IRSpy::Utils.pm";
+# This function is made available in xslt using the register_function call
+sub xslt_strcmp {
+ my ($arg1, $arg2) = @_;
+ return ($arg1->to_literal()) cmp ($arg2->to_literal());
+}
1;
<?xml version="1.0"?>
<!--
- $Id: irspy2zeerex.xsl,v 1.13 2006-12-11 11:01:14 sondberg Exp $
+ $Id: irspy2zeerex.xsl,v 1.14 2006-12-11 13:58: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:variable name="old_indexes" select="/*/explain:indexInfo/explain:index"/>
<xsl:variable name="use_attr_names" select="document('use-attr-names.xml')"/>
+ <xsl:variable name="ping_date" select="/*/irspy:status/irspy:probe[last()]"/>
<xsl:template match="/*">
<xsl:copy-of select="explain:serverInfo"/>
<xsl:copy-of select="explain:databaseInfo"/>
<metaInfo>
- <dateModified><xsl:value-of
- select="/*/irspy:status/*[last()]"/></dateModified>
+ <dateModified><xsl:value-of select="$ping_date"/></dateModified>
</metaInfo>
</xsl:template>
<!--
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.
- Simply add "| irspy:xxx" to the select attribute.
-->
<xsl:template name="insert-irspySection">
<irspy:status>
- <xsl:for-each select="*/irspy:probe |
- */irspy:boolean |
- */irspy:named_resultset |
- */irspy:explain">
+ <xsl:for-each
+ select="*/irspy:probe |
+ */irspy:boolean[irspy:strcmp(text(), $ping_date) >= 0] |
+ */irspy:named_resultset[irspy:strcmp(text(),$ping_date) >= 0]|
+ */irspy:explain[irspy:strcmp(text(),$ping_date) >= 0]">
<xsl:copy-of select="."/>
</xsl:for-each>
</irspy:status>