Re: "Protocol scheme 'c' is not supported ..."
Robin Berjon <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
On Oct 1, 2009, at 17:35 , Allen, Christopher wrote: > I have a doc that refers to a DTD like this: > > <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> > > and the doc's "outer element" is: > > <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" > debug="false"> > > I'm trying to read the doc with: > > $cxml = XML::XPath->new(filename => $cfile); > > and I get this error: > > 501 Protocol scheme 'c' is not supported c:/dir/subdir/log4j.dtd > Handler couldn't resolve external entity at line 2, column 48, byte 87 > error in processing external entity reference at line 2, column 48, > byte > 87: > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> > ===============================================^ > > I have XML::XPath version 1.13. Any help? Thanks, This looks like the underlying XML::Parser is trying to resolve the DTD, seeing some form of normalised Windows path when it expects a URI, and therefore interprets the c as a URI scheme — which can only fail. The simplest solution here is to never ever use DTDs. Just kill that DOCTYPE, it's useless at best and harmful most of the time. If you can't do that though because it's a document you're receiving from elsewhere and don't feel comfortable regexing that wart out of its misery, or — Eris forbid — processing the document actually requires the presence of the external subset then you'll have to configure XML::Parser to handle it. You can pass an XML::Parser that you configure yourself to XML::XPath with the "parser" option my $p = XML::Parser->new(...); my $xp = XML::XPath->new( parser => $p ); Now there are several things you can try. The first would be to give XML::Parser the NoLWP option: my $p = XML::Parser->new( NoLWP => 1 ); If that doesn't work, you'll have to play with the ExternEnt and ExternEntFin handlers — that's longer to explain, so write back with your progress if the previous option doesn't work. -- Robin Berjon - http://berjon.com/ _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs