[jdom-interest] Problem with DOMBuilder

Herb Jiang herb at intumit.com
Tue Jan 30 19:51:04 PST 2001


I use Xerces 1.2.3 API + JDOM-b5.

I cannot use DOMBuilder to build a DOM Document Object from xml file.

I get this error:
Exception in thread "main" org.jdom.IllegalNameException: The name "null" is not legal for JDOM/XML elements: XML names cannot be null or empty.
        at org.jdom.Element.<init>(Element.java:140)
        at org.jdom.Element.<init>(Element.java:163)
        at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:289)
        at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:277)
        at org.jdom.input.DOMBuilder.build(DOMBuilder.java:238)
        at DOMBuilderTest.main(DOMBuilderTest.java:41)

when running this code with a very simple xml document file:

import java.io.*;
import javax.xml.parsers.*;
import org.apache.xerces.jaxp.*;

import org.jdom.*;
import org.jdom.input.*;


public class DOMBuilderTest {
	DocumentBuilderFactory doc_bf;

	public DOMBuilderTest() {
		doc_bf = new DocumentBuilderFactoryImpl();
	}

	public org.w3c.dom.Document getDOMDocument(String filename) {
		try {
			FileInputStream filereader = new FileInputStream(inputsource);
			DocumentBuilder doc_builder = doc_bf.newDocumentBuilder();
			return doc_builder.parse(filename);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}


	public static void main(String args[]) {
		
		DOMBuilderTest dom_bt = new DOMBuilderTest();
		org.w3c.dom.Document dom_doc = dom_bt.getDOMDocument(args[0]);

		DOMBuilder dom_builder = new DOMBuilder();
		Document jdom_doc = dom_builder.build(dom_doc);
	}
}






More information about the jdom-interest mailing list