Skip Menu |

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

Report information
The Basics
Id: 125511
Status: open
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: chrispitude [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 3.52
Fixed in: (no value)



Subject: after using set_id() and wrap_children(), elt_id() returns incorrect element
In this testcase, I have two handlers: A 'title' handler moves the ID value of "ID1" from a title element to its parent. A 'chapter' handler wraps the contents of the chapter (including the title). When processing is finished, it is the chapter element that has id==ID1. However, elt_id('ID') incorrectly returns the original title element instead; it is somehow not aware of the ID manipulation by the title handler.
Subject: bug_id.pl
#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $xml = <<EOF; <?xml version="1.0" encoding="UTF-8"?> <manual> <chapter> <number/> <title id="ID1">Title 1</title> </chapter> <chapter> <number/> <title id="ID2">Title 2</title> </chapter> </manual> EOF my $twig=XML::Twig->new; $twig->setTwigHandlers({ 'title' => sub { my $id = $_->id; $_->del_id; $_->parent->set_id($id); return 1; }, 'chapter' => sub { $_->wrap_children('.*', 'body'); return 1; }, }); $twig->parse($xml); (my $e) = ($twig->get_xpath('//*[@id="ID1"]')); $twig->print(pretty_print => 'indented'); print "\n\nfinding element id=ID1 by using xpath[\@id='ID1']: ".$e->xpath."\n\n"; print ' finding element id=ID1 by elt_id(\'ID1\'): '.$twig->elt_id('ID1')->xpath."\n"; print ' ^^^ id of this xpath:'.($twig->get_xpath($twig->elt_id('ID1')->xpath))[0]->id."\n";
Subject: Re: [rt.cpan.org #125511] after using set_id() and wrap_children(), elt_id() returns incorrect element
Date: Thu, 7 Jun 2018 11:14:48 +0200
To: bug-XML-Twig [...] rt.cpan.org
From: mirod <xmltwig [...] gmail.com>
That's a weird one. It looks like del_id doesn't update the ID => element hash properly. I can't figure out why though. Thanks for the report. -- mirod On 07/06/18 05:01, chrispitude@gmail.com via RT wrote: Show quoted text
> Wed Jun 06 23:01:53 2018: Request 125511 was acted upon. > Transaction: Ticket created by chrispitude@gmail.com > Queue: XML-Twig > Subject: after using set_id() and wrap_children(), elt_id() returns > incorrect element > Broken in: 3.52 > Severity: Critical > Owner: Nobody > Requestors: chrispitude@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125511 > > > > In this testcase, I have two handlers: > > A 'title' handler moves the ID value of "ID1" from a title element to its parent. > A 'chapter' handler wraps the contents of the chapter (including the title). > > When processing is finished, it is the chapter element that has id==ID1. However, elt_id('ID') incorrectly returns the original title element instead; it is somehow not aware of the ID manipulation by the title handler. >
Subject: Re: [rt.cpan.org #125511] after using set_id() and wrap_children(), elt_id() returns incorrect element
Date: Thu, 7 Jun 2018 06:48:31 -0400
To: bug-XML-Twig [...] rt.cpan.org
From: Chris Papademetrious <chrispitude [...] gmail.com>
I hate that kind of bug. :( The original testcase was megabytes of XML spread across several files. I spent a full day simplifying it because I figured it was going to be hard enough on your side! - Chris On Thu, Jun 7, 2018 at 5:15 AM, xmltwig@gmail.com via RT < bug-XML-Twig@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125511 > > > That's a weird one. > > It looks like del_id doesn't update the ID => element hash properly. I > can't figure out why though. > > Thanks for the report. > > -- > mirod > > > On 07/06/18 05:01, chrispitude@gmail.com via RT wrote:
> > Wed Jun 06 23:01:53 2018: Request 125511 was acted upon. > > Transaction: Ticket created by chrispitude@gmail.com > > Queue: XML-Twig > > Subject: after using set_id() and wrap_children(), elt_id() returns > > incorrect element > > Broken in: 3.52 > > Severity: Critical > > Owner: Nobody > > Requestors: chrispitude@gmail.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125511 > > > > > > > In this testcase, I have two handlers: > > > > A 'title' handler moves the ID value of "ID1" from a title element to
> its parent.
> > A 'chapter' handler wraps the contents of the chapter (including the
> title).
> > > > When processing is finished, it is the chapter element that has id==ID1.
> However, elt_id('ID') incorrectly returns the original title element > instead; it is somehow not aware of the ID manipulation by the title > handler.
> >
> >
Subject: Re: [rt.cpan.org #125511] after using set_id() and wrap_children(), elt_id() returns incorrect element
Date: Thu, 7 Jun 2018 08:55:45 -0400
To: bug-XML-Twig [...] rt.cpan.org
From: Chris Papademetrious <chrispitude [...] gmail.com>
Tangential question - did you get the emails I sent from my @synopsys.com account to your @gmail.com account? Our work spam filter is *very* unreliable for incoming email... I have to log into a portal and do various other gymnastics to see filtered mails. I know you're busy, so thank you for finding time to support my effort. I'm currently in the critical path for our team, which makes this a bit exciting and terrifying. :) - Chris On Thu, Jun 7, 2018 at 6:48 AM, Chris Papademetrious <chrispitude@gmail.com> wrote: Show quoted text
> I hate that kind of bug. :( > > The original testcase was megabytes of XML spread across several files. I > spent a full day simplifying it because I figured it was going to be hard > enough on your side! > > - Chris > > > > On Thu, Jun 7, 2018 at 5:15 AM, xmltwig@gmail.com via RT < > bug-XML-Twig@rt.cpan.org> wrote: >
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=125511 > >> >> That's a weird one. >> >> It looks like del_id doesn't update the ID => element hash properly. I >> can't figure out why though. >> >> Thanks for the report. >> >> -- >> mirod >> >> >> On 07/06/18 05:01, chrispitude@gmail.com via RT wrote:
>> > Wed Jun 06 23:01:53 2018: Request 125511 was acted upon. >> > Transaction: Ticket created by chrispitude@gmail.com >> > Queue: XML-Twig >> > Subject: after using set_id() and wrap_children(), elt_id()
>> returns
>> > incorrect element >> > Broken in: 3.52 >> > Severity: Critical >> > Owner: Nobody >> > Requestors: chrispitude@gmail.com >> > Status: new >> > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125511 > >> > >> > >> > In this testcase, I have two handlers: >> > >> > A 'title' handler moves the ID value of "ID1" from a title element to
>> its parent.
>> > A 'chapter' handler wraps the contents of the chapter (including the
>> title).
>> > >> > When processing is finished, it is the chapter element that has
>> id==ID1. However, elt_id('ID') incorrectly returns the original title >> element instead; it is somehow not aware of the ID manipulation by the >> title handler.
>> >
>> >>
>