Q: org.xml.sax.SAXParseException: File "xxxxxxxx.dtd" not found.
Applies to: 1.x, 2.0
When parsing a map, action, or filter document, I get the error:
org.xml.sax.SAXParseException: File "xxxxxxxx.dtd" not found.
where xxxxxxxx.dtd is xmldbms.dtd, xmldbms2.dtd, actions.dtd, or filters.dtd.
This error occurs because the parser (usually Xerces 1.x) does not resolve the relative URL and look for the DTD in the same directory in which the map, filter, or action document occurs. There are two solutions to this problem. The first (not tested by me, but stated in the Xerces mailing list archives) is to use Xerces 2.0 or later. These versions of Xerces apparently resolve relative paths relative to the XML file.
If it is not possible to upgrade your parser, the solution is to use a file URL and specify the complete path to the DTD. For example, change:
<!DOCTYPE XMLToDBMS SYSTEM "filters.dtd"> <XMLToDBMS> ... <XMLToDBMS>
<!DOCTYPE XMLToDBMS SYSTEM "file://localhost/c|/xmldbms/samples/filters.dtd"> <XMLToDBMS> ... <XMLToDBMS>
On Windows systems, be sure to replace the colon (:) after the drive letter with a vertical bar (|) and the backslashes (\) between directory names with forward slashes (/). Note that some systems incorrectly support the use of colons and backslashes -- you may have to try both syntaxes to find out what works on your system. Note also that the "localhost" host name is optional. If you omit this, be careful to use three forward slashes (///) after the file: scheme name rather than two forward slashes (//).)
One consequence of this solution is that there does not appear to be an easy way to write map, action, and filter documents that are portable from system to system, as the path to the DTD must be hard-coded and there is no guarantee that the DTD can be placed in the same directory on all systems.
Back to the XML-DBMS FAQs