[jdom-interest] Bug when handling the file path of a DTD.

TassoA at trustmarque.ca TassoA at trustmarque.ca
Thu Jan 25 12:54:11 PST 2001

I think that the SAXBuilder and DOMBuilder handle the path of the DTD
differentl. The path pointing to the DTD of SAXBuilder is different from the
path of DOMBuilder. From the trace it can also be XERCES.

Here is the source code, under the source is the output.

import java.io.File;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.*;

public class jdomtest {

  public jdomtest() {
  public static void main(String[] args) {

    if(args.length != 1)
      System.out.println("Uasage: jdomtest [filename]");


      SAXBuilder builder1 = new SAXBuilder(true);
      Document doc1 = builder1.build(new File(args[0]));
      System.out.println("SAX: Document successfully read");

      DOMBuilder builder2 = new
      Document doc2 = builder2.build(new File(args[0]));
      System.out.println("DOM: Document successfully read");

    catch(JDOMException e)


This is teh DTD declaration within the XML file.
<!DOCTYPE STLink:Transaction SYSTEM "STLinkTransaction.dtd">
Both the DTD and XML file are within the same folder called Data.


jdomtest ./Data/STLinkTransaction.xml

SAX: Document successfully

read org.jdom.JDOMException: Error on line 0 of XML document: File
"file:///D:/Projects/Java/Tests/JDOM/STLinkTransaction.dtd" not found.:
Error on line 0 of XML document: File
"file:///D:/Projects/Java/Tests/JDOM/STLinkTransaction.dtd" not found. 	
	at org.jdom.input.DOMBuilder.build(DOMBuilder.java:194) 
	at org.jdom.input.DOMBuilder.build(DOMBuilder.java:216)
	at jdomtest.main(jdomtest.java:39)
Root cause: java.io.IOException: Error on line 0 of XML document: File
"file:///D:/Projects/Java/Tests/JDOM/STLinkTransaction.dtd" not found.
	at org.jdom.input.DOMBuilder.build(DOMBuilder.java:188)
	at org.jdom.input.DOMBuilder.build(DOMBuilder.java:216) 
	at jdomtest.main(jdomtest.java:39) 

More information about the jdom-interest mailing list