|Subject:||adding a document fragment as a documentElement doesn't work|
if I try adding a document-fragment to a document, I get a silent failure. It doesn't add the (only) child of the fragment, nor does it generate a warning. The pod for DocumentFragment suggests that you can use it anywhere you can insert a node, but if this is an intentional exception, a warning would be nice. I've attached minimal code to demonstrate the issue.
use XML::LibXML; my $frag = XML::LibXML::DocumentFragment->new; my $node = XML::LibXML::Element->new('foo'); $frag->appendChild($node); print $frag->toString, "\n"; my $doc = XML::LibXML::Document->new; $doc->setDocumentElement($frag); print $doc->toString, "\n"; $doc->setDocumentElement($node); print $doc->toString, "\n";