Subject: | <!DOCTYPE> header is stripped from output. |
'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata herd="perl"></pkgmetadata>
');
say scalar $xml->data;
---
<?xml version="1.0" encoding="utf-8" ?>
<?meta name="GENERATOR" content="XML::Smart/1.6.9 Perl/5.015009 [linux]" ?>
<pkgmetadata herd="perl"/>
You can of course make the DTD validate and work correctly with apply_dtd, however, it does this:
use XML::Smart;
my $xml = XML::Smart->new(
'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata herd="perl"></pkgmetadata>
');
$xml->apply_dtd('http://www.gentoo.org/dtd/metadata.dtd');
say scalar $xml->data;
<?xml version="1.0" encoding="utf-8" ?>
<?meta name="GENERATOR" content="XML::Smart/1.6.9 Perl/5.015009 [linux]" ?>
<!ELEMENT packages ( pkgmetadata* )>
<!ELEMENT catmetadata ( (longdescription)* )>
<!ELEMENT pkgmetadata ( (herd|maintainer|longdescription|use|upstream)* )>
<!ELEMENT herd (#PCDATA)>
<!ELEMENT maintainer ( email, (description| name)* )>
<!ELEMENT longdescription (#PCDATA|pkg|cat)* >
<!ELEMENT changelog (#PCDATA|change)* >
<!ELEMENT change (date,(developer|version|description|file|contributor|bug)*) >
<!ELEMENT date (#PCDATA) >
<!ELEMENT developer (name?,email) >
<!ELEMENT version (#PCDATA) >
<!ELEMENT file (#PCDATA) >
<!ELEMENT contributor (name?,email?) >
<!ELEMENT bug (#PCDATA) >
<!ELEMENT use (flag)* >
<!ELEMENT flag (#PCDATA|pkg|cat)* >
<!ELEMENT upstream (maintainer|changelog|doc|bugs-to|remote-id)* >
<!ELEMENT doc (#PCDATA)>
<!ELEMENT bugs-to (#PCDATA)>
<!ELEMENT remote-id (#PCDATA)>
<!ELEMENT pkg (#PCDATA) >
<!ELEMENT cat (#PCDATA) >
<!ELEMENT email (#PCDATA) >
<!ELEMENT name (#PCDATA) >
<!ELEMENT description (#PCDATA) >
<!ATTLIST catmetadata pkgname CDATA "">
<!ATTLIST pkgmetadata pkgname CDATA "">
<!ATTLIST flag name CDATA #REQUIRED >
<!ATTLIST maintainer status (active|inactive|unknown) "unknown" >
<!ATTLIST doc lang CDATA "C" >
<!ATTLIST remote-id type (freshmeat|sourceforge|sourceforge-jp|cpan|vim|google-code|ctan|pypi|rubyforge|cran) #REQUIRED>
<!ATTLIST description lang CDATA "C" >
<!ATTLIST longdescription lang CDATA "C" >
<!ATTLIST use lang CDATA "C" >
<!ATTLIST herd restrict CDATA #IMPLIED >
<!ATTLIST maintainer restrict CDATA #IMPLIED >
<!ATTLIST longdescription restrict CDATA #IMPLIED >
<!ATTLIST flag restrict CDATA #IMPLIED >
<pkgmetadata>
<herd>perl</herd>
</pkgmetadata>
Which is pretty disgusting.
And the only alternative is to put: nodtd => 1, which omits the DTD declaration entirely:
$xml->apply_dtd('http://www.gentoo.org/dtd/metadata.dtd');
say scalar $xml->data( nodtd => 1 );
<?xml version="1.0" encoding="utf-8" ?>
<?meta name="GENERATOR" content="XML::Smart/1.6.9 Perl/5.015009 [linux]" ?>
<pkgmetadata>
<herd>perl</herd>
</pkgmetadata>
is there a better way to do this?
Asides from that, <3 XML::Smart. Works Like Win.