Re: Using XML::LibXML::SAX::Parser as replacement for XML::LibXML::SAX::Generator

Robin Berjon <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
On Apr 7, 2010, at 22:17 , Kjetil Kjernsmo wrote:
>>> the doctype declaration,
>> 
>> Still assuming $doc holds the Document, with $root from above, and
>> $pubId and $sysId retrieved from the proper places:
>> 
>> $doc->setExternalSubset($doc->createExternalSubset($root->tagName,
>> $pubId, $sysId));
> 
> Hmmm, I tried 
> my $xpc = XML::LibXML::XPathContext->new($orig);
> $xpc->registerNs('rat', $self->{DOC}->{RATURI});
> $xpc->registerNs('xhtml', 'http://www.w3.org/1999/xhtml');
> my ($system_id) = $xpc->findnodes('/xhtml:html/@rat:doctype-system') || 
> 'http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd';
> my ($public_id) = $xpc->findnodes('/xhtml:html/@rat:doctype-public') || 
> '-//W3C//DTD XHTML+RDFa 1.0//EN';
> my $dtd = XML::LibXML::Dtd->new($public_id, $system_id); 
> my $output = $builder->result;
> $output->setExternalSubset($dtd);
> 
> But that took ages to run, and I assumed that XML::LibXML::Dtd tried to 
> download the resource identified by the system ID... Does your code do the 
> same thing? I just want to prefix the string... :-)

To be honest, I have no sweet effing clue what it does under the hood for either your code or mine. That was the "right" way to do this, but what I really do in my code is remove the XML declaration with brutal prejudice if it's there, and just prepend the DOCTYPE in the few unfortunate cases in which it's needed.

-- 
Robin Berjon - http://berjon.com/



_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.