Skip Menu |

This queue is for tickets about the XML-XPath CPAN distribution.

Report information
The Basics
Id: 6362
Status: resolved
Priority: 0/
Queue: XML-XPath

People
Owner: MANWAR [...] cpan.org
Requestors: MIROD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.13
Fixed in: 1.18



Subject: Duplicates are not removed from the result list
Duplicates are not removed from the result list The following test case demonstrates it. The attached patch fixes it. #!/usr/bin/perl -w use strict; use XML::XPath; use Test::More; my $xml='<root att="root_att"><daughter att="3"/><daughter att="4"/><daughter att="5"/></root>'; my %results= ( '/root/daughter/..' => 'root[root_att]',); plan tests => scalar keys %results; my $xpath = XML::XPath->new( xml => $xml); foreach my $path ( keys %results) { my @xpath_result = $xpath->findnodes( $path); is( dump_nodes( @xpath_result) => $results{$path}, "path: $path"); } sub dump_nodes { return join '-', map { $_->getName . "[" . $_->getAttribute( 'att') . "]" } @_ }
--- NodeSet.pm 2002-09-02 12:25:47.000000000 +0200 +++ NodeSet.pm.new 2004-05-19 18:20:24.704899288 +0200 @@ -18,9 +18,23 @@ sub sort { my $self = CORE::shift; @$self = CORE::sort { $a->get_global_pos <=> $b->get_global_pos } @$self; + $self->remove_duplicates; return $self; } +sub remove_duplicates { + my $self = CORE::shift; + my @unique; + my $last_node=0; + foreach my $node (@$self) { + push @unique, $node unless( $node == $last_node); + $last_node= $node; + } + @$self= @unique; + return $self; +} + + sub pop { my $self = CORE::shift; CORE::pop @$self;
Subject: Re: [rt.cpan.org #6362] Duplicates are not removed from the result list
Date: Fri, 05 Jun 2015 18:14:40 +0200
To: bug-XML-XPath [...] rt.cpan.org
From: mirod <xmltwig [...] gmail.com>
On 06/05/2015 04:48 PM, Jonathan Stowe via RT wrote: Show quoted text
You scared me! I had completely forgotten this ticket, and for a while I thought that I had been made maintainer of XML::XPath. What a nightmare! ;--) Thanks though. -- mirod
Resolved.