Skip Menu |

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

Report information
The Basics
Id: 17064
Status: resolved
Priority: 0/
Queue: XML-Twig

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

Bug Information
Severity: (no value)
Broken in: 3.22
Fixed in: 3.23



Subject: XML::Twig cannot parse comments at EOF
Date: Fri, 13 Jan 2006 18:39:32 -0800
To: bug-XML-Twig [...] rt.cpan.org
From: Dan Dascalescu <ddascalescu [...] gmail.com>
my $twig= new XML::Twig( comments => 'process', )->parse("<root></root><!-- some comment -->"); Hope that helps, Dan Dascalescu http://dandv.blogspot.com
Hi, Indeed, it is a bug. The development version fixes it whith comments => 'keep' (the default). I am working on getting it to work with comments => 'process'. __ mirod
The new development version should work better now. __ mirod
Subject: Re: [rt.cpan.org #17064] XML::Twig cannot parse comments at EOF
Date: Wed, 18 Jan 2006 00:40:13 -0800
To: bug-XML-Twig [...] rt.cpan.org
From: Dan Dascalescu <ddascalescu [...] gmail.com>
Thanks for fixing it so quickly! Dan On 1/17/06, via RT <bug-XML-Twig@rt.cpan.org> wrote: Show quoted text
> The new development version should work better now.
Subject: Re: [rt.cpan.org #17064] XML::Twig cannot parse comments at EOF
Date: Wed, 18 Jan 2006 10:07:18 +0100
To: bug-XML-Twig [...] rt.cpan.org
From: Michel Rodriguez <mirod [...] xmltwig.com>
ddascalescu@gmail.com via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=17064 > > > Thanks for fixing it so quickly!
No problem, it lead me to refactor a bit the code that deals with comments and pi's and to make it simpler and (I hope!) more robust. Note that I changed a bit the internals. For more info that you might have wanted: - comments and pi's before the root are in + $twig->{leading_cpi} in "process" mode: they are all children of a single element #CPI) + or in $root->{extra_data} (in "keep" mode), - comments and pi's after the root are in + $twig->{trailing_cpi} ( elements, in "process" mode, children of a '#CPI' element) + and/or in $twig->{trailing_cpi_text} (you could have PI's in "process" mode for example and comments in "keep" mode, in which case comments before PIs would be in each PI's extra_data, and comments after the last PI would be in $twig->{trailing_cpi_text} It's complicated, but the net result is that it should work nicely if you don't care about all of this. That said, I realize I haven't tested it with flush, so there might be an updated version soon. -- Michel Rodriguez Perl &amp; XML xmltwig.com
Subject: Re: [rt.cpan.org #17064] XML::Twig cannot parse comments at EOF
Date: Wed, 18 Jan 2006 02:11:52 -0800
To: bug-XML-Twig [...] rt.cpan.org
From: Dan Dascalescu <ddascalescu [...] gmail.com>
Speaking of things before root, I noticed in all versions, including this latest development one, that you have no control over the whitespace between the DOCTYPE and the root element, even with keep_spaces => 1. my $twig = XML::Twig->new(keep_spaces => 1)->parse('<!DOCTYPE xliff PUBLIC "-//XML-INTL XLIFF-XML 1.0//EN" "file:xliff.dtd"> <root></root>')->print; # The CR/LFs before <root> won't be printed. Could this maybe be addressed? In my application, it would be nice to output the whitespace exactly as it was read. Thanks, Dan
Subject: Re: [rt.cpan.org #17064] XML::Twig cannot parse comments at EOF
Date: Wed, 18 Jan 2006 11:55:14 +0100
To: bug-XML-Twig [...] rt.cpan.org
From: Michel Rodriguez <mirod [...] xmltwig.com>
ddascalescu@gmail.com via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=17064 > > > Speaking of things before root, I noticed in all versions, including > this latest development one, that you have no control over the > whitespace between the DOCTYPE and the root element, even with > keep_spaces => 1. > > my $twig = XML::Twig->new(keep_spaces => 1)->parse('<!DOCTYPE xliff > PUBLIC "-//XML-INTL > XLIFF-XML 1.0//EN" "file:xliff.dtd"> > > > <root></root>')->print; > > > # The CR/LFs before <root> won't be printed. > > Could this maybe be addressed? In my application, it would be nice to > output the whitespace exactly as it was read.
Short answer: probably not. Long answer: those line returns are not sent to the character handler, like data within the root element, but rather to the default handler (of XML::Parser). It looks like it would be a little difficult to figure out which data should be kept with the root element, and which is part of the doctype/dtd. I might try, but this is not very high on my priority list ;--( BTW, there was indeed a problem with flush-ing comments/pi's after (and before!) the root element, it is fixed in the latest dv version (dated Wed Jan 18 11:33:45 2006). -- Michel Rodriguez Perl &amp; XML xmltwig.com