Subject: | makeNewNode failes to correctly set the new node name |
Test case:
use XML::EasyOBJ;
my $doc = new XML::EasyOBJ(-type => 'new', -param => 'root_tag');
my $newnode=$doc->makeNewNode('hello');
print $newnode->getTagName()."\n";
$dom=$doc->getDomObj;
print $dom->toString()."\n";
Output:
makeNewNode
<root_tag><makeNewNode/></root_tag>
Expected output:
hello
<root_tag><hello/></root_tag>
I'm not sure the best approach to fixing this bug, but I was able to
write a patch that "fixes" the problem, and returns the expected output
above.
Here's the unified diff:
+++ EasyOBJ.pm 2010-01-13 04:57:26.000000000 -0800
@@ -184,6 +184,7 @@
getAttr => 'getAttr',
setAttr => 'setAttr',
remAttr => 'remAttr',
+ makeNewNode => 'makeNewNode',
remElement => 'remElement',
getElement => 'getElement',
getDomObj => 'getDomObj',
@@ -283,6 +284,19 @@
=cut
+$SUBLIST{'makeNewNode'} =
+ sub {
+ my $self = shift;
+ my $element_name = shift;
+ return bless(
+ { map => $self->{map},
+ doc => $self->{doc},
+ ptr => &{$INTSUBLIST{'makeNewNode'}}(
$self, $element_name ),
+ expref => $self->{expref},
+ }, 'XML::EasyOBJ::Object' );
+ };
+
+
$INTSUBLIST{'makeNewNode'} =
sub {
my $self = shift;
(This bug was and it's patch were replicated on EasyOBJ 1.12 on
Slackware/Perl 5.8.6, Ubuntu 9.04/Perl 5.10.0 and Windows/Perl 5.10.1).