When parsing an XML file with the SAXParser class, you may run into an error related to a
.dtd file that cannot be found.
Example: We are parsing the file
The first lines of the XML are:
<?xml version="1.0"?> <!DOCTYPE HG-EntrySet PUBLIC "-//NCBI//HomoloGene/EN" "HomoloGene.dtd"> <HG-EntrySet> <HG-EntrySet_entries> <HG-Entry> <HG-Entry_hg-id>3</HG-Entry_hg-id>
We see a DOCTYPE declaration that points to a DTD file. DTD stands for Document Type Definition, and it is used to define the format of the XML file. The SAXParser will automatically look for this file in the same directory as the XML file.
When parsing we get the following error:
java.io.FileNotFoundException: D:\homologene\build65\HomoloGene.dtd (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown