Re: problem with external ID and XML::XPATH parse
Robin Berjon <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
Hi,
On Apr 8, 2010, at 23:39 , Avraham Shapiro wrote:
> This is strictly compliant with the XML spec. Yet when I parse the file with the externalID naming the DTD,
> I always get the following:
>
> Parse of 65984.opf failed
> 404 File `G:\AVI\mothership\initial-prototype\bat\oebpkg101.dtd' does not exist file:///G:/AVI/mothership/initial-prototype/bat/oebpkg101.dtd
> Handler couldn't resolve external entity at line 2, column 91, byte 133
> error in processing external entity reference at line 2, column 91, byte 133:
>
> when the cwd is not the same as the directory containing the document being parsed.
Something tells me that this is not an XML::XPath problem, but an XML::Parser problem. Do you get the same error with the following?
perl -MXML::Parser -e "XML::Parser->new(Style => 'Debug')->parsefile('path/to/file.xml')"
If so it's probably that the default external entity resolver that XML::Parser uses (which varies depending on what you have installed, but given the "404" in your error message I'm betting LWP) is somehow failing. You can read more about how this works (or rather, fails to work) at:
http://search.cpan.org/~msergeant/XML-Parser-2.36/Parser.pm#ExternEnt_%28Expat,_Base,_Sysid,_Pubid%29
There are several solutions here:
- Stop using DTDs, they're pretty much useless anyway (am I repeating myself? :)
- Switch from XML::XPath to XML::LibXML
- Figure out why XML::Parser's default resolver is going awry and submit a patch
- Configure your own instance of XML::Parser with a resolver that works for you, and set it as the parser that XML::XPath uses (see the documentation for XML::XPath::XMLParser)
The fourth option is the simplest I guess, but that's up to you of course :)
--
Robin Berjon - http://berjon.com/
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs