Re: External references in xml headers
Michael Ludwig <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
[email protected] schrieb: > Sorry for newbie question but i cannot figure out how to resolve > following problems. There are references to the dtd files at the > beginning of xml files: > > 1) If there is external references to public dts's like > 'http://www.w3.org/TR/REC-SMIL/SMIL10.dtd' the parser (XML::SPath) > sometimes dies due to network or access error to given url. I guess you mean XML::XPath. This may work fine, but hasn't seen any updates in a while. Personally, I'd rather use XML::LibXML, which is the Perl interface to the C library LibXML2, and definitely works a lot better. > 2) Sometimes there is only reference to SMIL10.dtd with no other > information and the parser also fails in this case. Can you give the exact line containing this reference? In case this reference simply will not resolve to a DTD (because there is none), the document is broken and the reference should be removed. As a workaround, then, in XML::LibXML, simply do the following: use strict; use warnings; use XML::LibXML; my $fnam = shift or die "Datei uebergeben"; my $parser = XML::LibXML->new; $parser->load_ext_dtd(0); my $doc = $parser->parse_file($fnam); > I have read a mechanism called catalogs and made a file > /etc/xml/catalog but there is something missing, that file > is not even read during xml parsing. This is basically a local cache of publicly available DTDs. Very useful! Where it is on your system, is, well, system-specific. In XML::LibXML, it can be configured via load_catalog($file). See XML::LibXML::Parser. Yes, another reason to use XML::LibXML. use strict; use warnings; use XML::LibXML; my $fnam = shift or die "Datei uebergeben"; my $fnam_xml_cat = shift || '/usr/share/xml/schema/xml-core/catalog.xml'; my $parser = XML::LibXML->new; $parser->load_catalog( $fnam_xml_cat ); my $doc = $parser->parse_file( $fnam ); Michael Ludwig _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs