X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=lib%2FZOOM%2FIRSpy%2FRecord.pm;h=c213f54a3655add5c9742f51f389d0c683e406ec;hb=6d728caadc58eef3c2b50ac6c190273b0ba11ab5;hp=7b4125ad02f89983379ebdda318224301f8b66e8;hpb=8b8318cf109cf0ea40ce888bada70a4ede6c5183;p=irspy-moved-to-github.git diff --git a/lib/ZOOM/IRSpy/Record.pm b/lib/ZOOM/IRSpy/Record.pm index 7b4125a..c213f54 100644 --- a/lib/ZOOM/IRSpy/Record.pm +++ b/lib/ZOOM/IRSpy/Record.pm @@ -1,4 +1,4 @@ -# $Id: Record.pm,v 1.12 2006-09-25 14:21:07 mike Exp $ +# $Id: Record.pm,v 1.15 2006-10-13 13:41:57 sondberg Exp $ package ZOOM::IRSpy::Record; @@ -29,7 +29,7 @@ I<## To follow> sub new { my $class = shift(); - my($target, $zeerex) = @_; + my($irspy, $target, $zeerex) = @_; if (!defined $zeerex) { $zeerex = _empty_zeerex_record($target); @@ -37,6 +37,7 @@ sub new { my $parser = new XML::LibXML(); return bless { + irspy => $irspy, target => $target, parser => $parser, zeerex => $parser->parse_string($zeerex)->documentElement(), @@ -89,7 +90,7 @@ sub append_entry { my $root = $this->{zeerex}; # XML::LibXML::Element ISA XML::LibXML::Node my $xc = XML::LibXML::XPathContext->new($root); $xc->registerNs(zeerex => "http://explain.z3950.org/dtd/2.0/"); - $xc->registerNs(irspy => "http://indexdata.com/irspy/1.0"); + $xc->registerNs(irspy => $ZOOM::IRSpy::irspy_ns); my @nodes = $xc->findnodes($xpath); if (@nodes == 0) { @@ -104,8 +105,8 @@ sub append_entry { if @nodes == 0; } - ZOOM::Log::log("irspy", - scalar(@nodes), " matches for '$xpath': using first") + $this->{irspy}->log("warn", + scalar(@nodes), " matches for '$xpath': using first") if @nodes > 1; $this->_half_decent_appendWellBalancedChunk($nodes[0], $frag); @@ -128,7 +129,7 @@ sub append_entry { # namespace mapping for that node -- but that only affects pre-parsed # trees, and is no use for parsing. Hence the following pair of lines # DOES NOT WORK: -# $node->setNamespace("http://indexdata.com/irspy/1.0", "irspy", 0); +# $node->setNamespace($ZOOM::IRSpy::irspy_ns, "irspy", 0); # $node->appendWellBalancedChunk($frag); # # Instead I have to go the long way round, hence this method. I have @@ -142,7 +143,7 @@ sub _half_decent_appendWellBalancedChunk { my($node, $frag) = @_; if (1) { - $frag =~ s,>, xmlns:irspy="http://indexdata.com/irspy/1.0">,; + $frag =~ s,>, xmlns:irspy="$ZOOM::IRSpy::irspy_ns">,; $node->appendWellBalancedChunk($frag); return; }