Skip Menu |

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

Report information
The Basics
Id: 49906
Status: resolved
Priority: 0/
Queue: XML-Bare

People
Owner: cpan [...] codechild.com
Requestors: nigel.metheringham [...] Dev.intechnology.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.45
Fixed in: 0.49



Subject: Simple mode reports content of empty node as integer 1
The simple mode will parse an empty node as a value 1 - ie <node/> ==> { node => 1 } This is indistinguishable from <node>1</node> The attached patch changes it so <node/> ==> { node => '' } <node></node> ==> { node => '' }
Subject: 0001-Modification-so-that-an-empty-node-has-an-empty-stri.patch
From 91c53af5e3e3c0d378530c95d7669685a575db74 Mon Sep 17 00:00:00 2001 From: Nigel Metheringham <nigel.metheringham@dev.intechnology.co.uk> Date: Tue, 22 Sep 2009 13:53:50 +0100 Subject: [PATCH] Modification so that an empty node has an empty string as its value in simple mode, and not the integer 1 --- Bare.xs | 2 +- t/Basic.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Bare.xs b/Bare.xs index 0c4b1a3..dde3b6f 100644 --- a/Bare.xs +++ b/Bare.xs @@ -154,7 +154,7 @@ SV *cxml2obj_simple() { SvUTF8_on(sv); return sv; } - return newSViv( 1 ); //&PL_sv_undef; + return newSVpv("", 0); // an empty tag has empty string content } output = newHV(); diff --git a/t/Basic.t b/t/Basic.t index a4e5cd6..bd11dad 100755 --- a/t/Basic.t +++ b/t/Basic.t @@ -16,7 +16,7 @@ is( $simple->{node}, 'val', 'simple - normal node value reading' ); ( $xml, $root, $simple ) = reparse( "<xml><node/></xml>" ); is( ref( $root->{xml}->{node} ), 'HASH', 'existence of blank node' ); -is( $simple->{node}, 1, 'simple - existence of blank node' ); +is( $simple->{node}, '', 'simple - existence of blank node' ); ( $xml, $root, $simple ) = reparse( "<xml><node att=12>val</node></xml>" ); is( $root->{xml}->{node}->{att}->{value}, '12', 'reading of attribute value' ); -- 1.6.4.2
The original behavior was intentional, as demonstrated by the fact that your 'patch' alters the test case. Test cases, typically, should not be altered. They demonstrate the exact behavior of a module. Several people have suggested that 'simple' should behave exactly like the 'XML::Simple' module. I will acquiesce and make some of these changes in order to satisfy these demands, because I can easily see why people may think this is intended. Note that your patch is wrong because it uses newSVpv, not newSVpvn. newSVpv automatically calculates string length when the length it set to 0. newSVpvn does not. In theory newSVpv as shown would take a couple more clock cycles. Also, I would like to point out that in the several years you were supposedly maintaining this module you never resolved this bug that you reported yourself. This is yet another reason you have been removed as a maintainer of the module. A suitable change has been made in version 0.49, which will be out shortly. Peace.