Bug (?) in XML::LibXML when creating XML docs with invalid characters

aitor <[email protected]> Tue, 9 Apr 2013 13:11:58 +0200
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
Hi,

the following perl snippet creates an invalid XML using LibXML
functions, which I though was not possible. The idea is to attach a
malformed character via "appendText". I would say that the function
should fail when feeding invalid characters ?

test.pl
*******

#!/usr/bin/perl

use XML::LibXML;

my $c = pack("W", 07); # the invalid character

my $odoc = XML::LibXML::Document->new('1.0',"UTF-8");
my $elem = $odoc->createElement("elem");
$odoc->setDocumentElement($elem);
$elem->appendText($c);
print $odoc->toString(1)."\n";

******
% perl test.pl > test.xml
% xmllint --noout test.xml
test.xml:2: parser error : PCDATA invalid Char value 7
<elem>lem>
      ^

Any ideas ?

best,
                                                aitor
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs