problem with external ID and XML::XPATH parse
"Avraham Shapiro" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
** Low Priority **
I have a problem with an XML::XPATH parse of an XML file with a doctype declaration under Windows XP, Perl 5.8.8.
The doctype follows the XML spec (numbers on lhs are production numbes):
[28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' intSubset ']' S?)? '>' [VC: Root Element Type]
where the external ID is included but not the internal Subset. The external id is just:
[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral
where the second alternative is used. So my DOCTYPE line is just:
<!DOCTYPE package PUBLIC "+//ISBN 0-9673008-1-9//DTD OEB 1.0.1 Package//EN" "oebpkg101.dtd" >
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.
Note the file:// URL specifier for the URI which is the system literal. This is a WRONG substitution because the file, oebpkg101.dtd lives
where the document lives which is certainly not in directory: G:/AVI/mothership/initial-prototype/bat. That diretory is the CWD
when the perl program runs. According to the XML spec the URI of the external entity is relative to the document it is found in:
>From 4.2.2 of the XML spec:
Unless otherwise provided by information outside the scope of this specification (e.g. a special XML element type defined by a particular DTD, or a processing instruction defined by a particular application specification), relative URIs are relative to the location of the resource within which the entity declaration occurs. This is defined to be the external entity containing the '<' which starts the declaration, at the point when it is parsed as a declaration.
Hence it's my belief that XML::XPATH is interpreting the external entity incorrectly when it appears in the DOCTYPE declaration
as the SystemLiteral.
Note that under Unix, this error doesn't happen, probably because the device letter is not confused with a mechanism specifier that
doesn't exist.
Thanks for your help
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs