Skip Menu |
 

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

Report information
The Basics
Id: 28960
Status: rejected
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: yona [...] cs.technion.ac.il
Cc:
AdminCc:

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



Subject: XML::Twig and whitespaces in element values and in attribute values
Date: Thu, 23 Aug 2007 17:37:27 +0300 (IDT)
To: bug-XML-Twig [...] rt.cpan.org.
From: Yona Shlomo <yona [...] cs.technion.ac.il>
Download (untitled) / with headers
text/plain 1.1k
Hello, This is the same issue that was reported at http://www.perlmonks.org/?node_id=634644 Here's the issue: I'm using XML::Twig and have noticed that it replaces white-space characters to spaces. Something like s/\s/ /g on all attribute and element values. See example code: #!/usr/bin/perl use strict; use warnings; use XML::Twig; my $twig=XML::Twig->new(); my $xml = qq{<root t="space tab\tnewline\nend"/>}; $twig->xparse($xml); my $text=$twig->root->att('t'); print "|$text|\n"; The expected output (contents of the scalar $text is the word space followed by a single space character, followed by the word tab, followed by a single tab character, followed by the word newline, followed by a single newline character, and then the word end. Instead, the tab and the newline characters were replaced by a single space character each. 1. Why? 2. How can I force XML::Twig to preserve whitespaces and not alter the text in any form? This relates to XML::Twig 3.29 and XML::Twig 3.30. I did not check this behavior in other versions of XML::Twig Thanks. -- Shlomo Yona yona@cs.technion.ac.il http://yeda.cs.technion.ac.il/~yona/
Subject: Re: [rt.cpan.org #28960] XML::Twig and whitespaces in element values and in attribute values
Date: Thu, 23 Aug 2007 11:18:23 -0400
To: bug-XML-Twig [...] rt.cpan.org
From: "Michel Rodriguez" <xmltwig [...] gmail.com>
Download (untitled) / with headers
text/plain 1.7k
On 8/23/07, yona@cs.technion.ac.il via RT <bug-XML-Twig@rt.cpan.org> wrote: Show quoted text
> > Thu Aug 23 10:38:35 2007: Request 28960 was acted upon. > Transaction: Ticket created by yona@cs.technion.ac.il > Queue: XML-Twig > Subject: XML::Twig and whitespaces in element values and in attribute values > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: yona@cs.technion.ac.il > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=28960 > > > > Hello, > > This is the same issue that was reported at > http://www.perlmonks.org/?node_id=634644 > > Here's the issue: > > I'm using XML::Twig and have noticed that it replaces > white-space characters to spaces. Something like s/\s/ /g on > all attribute and element values. > > See example code: > > #!/usr/bin/perl use strict; > use warnings; > use XML::Twig; > my $twig=XML::Twig->new(); > my $xml = qq{<root t="space tab\tnewline\nend"/>}; > $twig->xparse($xml); > my $text=$twig->root->att('t'); > print "|$text|\n"; > > > The expected output (contents of the scalar $text is the > word space followed by a single space character, followed by > the word tab, followed by a single tab character, followed > by the word newline, followed by a single newline character, > and then the word end. > > Instead, the tab and the newline characters were replaced by > a single space character each. > > 1. Why? > 2. How can I force XML::Twig to preserve whitespaces and not > alter the text in any form? > > This relates to XML::Twig 3.29 and XML::Twig 3.30. I did not > check this behavior in other versions of XML::Twig
This is not a bug, it is mandated by the XML spec, see my answer on perlmonks in the same thread. -- mirod
Subject: Re: [rt.cpan.org #28960] XML::Twig and whitespaces in element values and in attribute values
Date: Sat, 25 Aug 2007 06:42:11 +0300 (IDT)
To: "xmltwig [...] gmail.com via RT" <bug-XML-Twig [...] rt.cpan.org>
From: Yona Shlomo <yona [...] cs.technion.ac.il>
Download (untitled) / with headers
text/plain 426b
On Thu, 23 Aug 2007, xmltwig@gmail.com via RT wrote: Show quoted text
> This is not a bug, it is mandated by the XML spec, see my answer on > perlmonks in the same thread.
Thanks, mirod. While your normalization seems to be the correct behavior (considering the w3c XML 1.0 recommendation) for attribute values, it is not the correct behavior for element values. -- Shlomo Yona yona@cs.technion.ac.il http://yeda.cs.technion.ac.il/~yona/
Download (untitled) / with headers
text/plain 644b
On Fri Aug 24 23:43:25 2007, yona@cs.technion.ac.il wrote: Show quoted text
> On Thu, 23 Aug 2007, xmltwig@gmail.com via RT wrote: >
> > This is not a bug, it is mandated by the XML spec, see my answer on > > perlmonks in the same thread.
> > Thanks, mirod. > > While your normalization seems to be the correct behavior > (considering the w3c XML 1.0 recommendation) for attribute > values, it is not the correct behavior for element values. >
Did you try using the keep_spaces option as suggested in the PM thread? If you tried and it did not keep whitespaces, then there is indeed a bug. Otherwise it is a well-documented feature of the module. __ mirod


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.