W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

HRE when adding to Doc created with DTD

From: James <jhughes@kos.net>
Date: Tue, 3 Apr 2001 20:42:11 -0400
To: www-dom@w3.org
Message-ID: <20010403204211.A994@kos.net>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT