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