HRE when adding to Doc created with DTD

Hello:

I am writing an application that parses a file into a DOM tree and then 
dynamically modifies the tree, or creates the DOM from scratch if the file 
doesn't exist.

I create my Document object like this:

*snip*
	ruledoc = new DocumentImpl();
*snip*
and add children to the root element (ruleset) like this:

*snip*
rule.getOwnerDocument().getFirstChild().appendChild(rule); // attach rule
							   //to ruleset
*snip*

My problem is as follows:
If I turn on validation with setFeature and create the Document like this:
*snip*
	// Set SYSTEM identifier
	ruledoc = new DocumentImpl(new DocumentTypeImpl((DocumentImpl)
			ruledoc,null,null,"file:\\" + dtdfile.toString()))); 
*snip*
I can create a new document, serialize it to a file, and parse it back out 
again. However, when I attempt to add to ruledoc using the above call to 
appendChild(), I get a Hierarchy Request Error.

Writing out the name of the root element with 
"out.print(rule.getOwnerDocument().getFirstChild().getNodeName()"
gives the same result in both cases.
I'm using xerces-J 1.3.0.
I would really like to be able to use the validation feature of DOMParser,
so any help in this matter would be greatly appreciated.

Thanks,
James Hughes

Received on Tuesday, 3 April 2001 20:31:01 UTC