tag 315628 patch
clone 315628 -1
reassign -1 libxml-xpathengine-perl 0.08-1
submitter -1 !
thanks

On Fri, Jun 24, 2005 at 03:01:47PM +1000, Alexander Zangerl wrote:
> Package: libxml-xpath-perl
> Version: 1.13-6
> Severity: normal
> 
> the stringification of literals (as returned by findvalue) should allow me
> to transparently use these like strings/numbers, but that does no longer work.
> 
> i'm assigning the result of a findvalue to a hash element (tried scalar, 
> fails in the same way), and then i do a multiplication with a constant on it. 
> 
> 1.13 fails with:
> Operation `*': no method found,
>         left argument has no overloaded magic,
>         right argument in overloaded package XML::XPath::Literal

Hi,

this can be fixed by adding 'fallback => 1' to the 'use overload'
line in XPath/Literal.pm.

The same problem is also present in other XPath modules as shown eg. by
CPAN #11724 for the case of XML::XPath::NodeSet.

 http://rt.cpan.org/Public/Bug/Display.html?id=11724

The list of modules with 'use overload' lines is

XML::XPath::Number
XML::XPath::Boolean
XML::XPath::Literal
XML::XPath::NodeSet

I can't think of a case where this is a problem for XML::XPath::Boolean,
but it certainly is for XML::XPath::Number (try eg. multiplying the
result of count() to see this.)

Unfortunately, XML::XPath is long dead upstream (see #458713). I
am a bit uneasy about breaking existing programs by fixing this in
Debian... haven't quite decided on this yet, but leaning on the fixing
side.

In any case, the problem is present in libxml-xpathengine-perl (a fork
of the same code that's alive upstream) too, so cloning. Test script
attached. This should be reported upstream on XML::XPathEngine.

Cheers,
-- 
Niko Tyni   [EMAIL PROTECTED]
#!/usr/bin/perl
use XML::DOM::XPath;
use strict;

my (%weights,$res);
my $parser = XML::DOM::Parser->new;
my $xp = $parser->parse(*DATA);

foreach my $component ($xp->findnodes ('//structure//assessments/component')) 
{
    my $id = $xp->findvalue ('@id',     $component);
    $weights{$id} = $xp->findvalue ('@weight', $component);

    $res=  100 * $weights{$id};	# this is where things fail. 
    print "res is $res\n";
}

__DATA__
<?xml version="1.0" encoding="utf-8"?>
<cdl><structure><assessments>
<component type="labtasks" name="Lab Tasks" id="labtasks"    weight="40"/>
<component type="exam"       name="Mid Term Exam"    id="midterm" weight="20"/>
<component type="exam"       name="End Term Exam"  id="endterm" weight="40"/>
</assessments></structure></cdl>

Reply via email to