libxml-raku / LibXML-raku

Raku bindings to the libxml2 native library
Artistic License 2.0
11 stars 5 forks source link

setExternalSubset() not working as documented #54

Closed dwarring closed 3 years ago

dwarring commented 3 years ago

Consider the following, slightly adapted from setExternalSubset doco:

use LibXML::Document;
use LibXML::Dtd;

my LibXML::Document $doc .= parse: string => '<foo/>';
my LibXML::Document $other-doc .= parse: :file<test/dtd/note-external.xml>, :dtd;

my LibXML::Dtd:D $dtd = $other-doc.getExternalSubset;
$doc.setExternalSubset: $dtd.clone();
note $doc.Str;

Output is:

<?xml version="1.0" encoding="UTF-8"?>
<foo/>

I.e. is being ignored and no affect on the output.

dwarring commented 3 years ago

setExternalSubset() sets a Dtd for validation only.

setInternalSubset() has been amended, along with doco. It now calls xmlCreateInSubset() to create a new Dtd, correctly inserted into the document's tree.

Further work needed to copy or construct validation rules.

dwarring commented 3 years ago

Redoing fix to bring it into line with Perl XML::LibXML.

Amending domSetInternalSubset to call xmlAddChildren xmlAddPrevSibling to link the node into document root. Somehow lost these lines during migration.

dwarring commented 3 years ago

domSetInternalSubset() now inserts the DtD into the document root, similar function in Perl XML::LibXML.

Also automatically make a copy of an imported DtD.