You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Brice Ruth <br...@webprojkt.com> on 2003/04/11 15:55:39 UTC
Getting error HIERARCHY_REQUEST_ERR ?!?
I'm using JAXP w/ JDK 1.4 (which I believe has an older version of
Xalan/Xerces integrated) to construct a DOM and output this DOM to an
XML file. Unfortunately, I'm having some issues actually constructing
the DOM!!
I create a 'Document' object from a DOMImplementation, then assign
'getDocumentElement()' to a Node object. So far, so good - no
exceptions. I then create an Element from the Document object, using
'createElement' and set some attributes on the element before trying to
append it to my 'root' Node, which I got from 'getDocumentElement()'
previously. It is at this point, in the 'appendChild' call, that I get
the exception HIERARCHY_REQUEST_ERR: This node isn't allowed here.
What's going on here?
Respectfully,
Brice Ruth
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Getting error HIERARCHY_REQUEST_ERR ?!?
Posted by Brice Ruth <br...@webprojkt.com>.
Christ. Sometimes it just takes someone to point out the obvious ... I
was grabbing the root node of the document after creating it with
createDocument(null,"root",null), assigning it to a Node object, but
then later on, when trying to append my first element to the root, I was
trying to append to the doc, not the root node I had retrieved.
Sorry for wasting everyone's time!!
Brice
Richard Rowell wrote:
>On Fri, 2003-04-11 at 08:55, Brice Ruth wrote:
>
>
>
>>I create a 'Document' object from a DOMImplementation, then assign
>>'getDocumentElement()' to a Node object. So far, so good - no
>>exceptions. I then create an Element from the Document object, using
>>'createElement' and set some attributes on the element before trying to
>>append it to my 'root' Node, which I got from 'getDocumentElement()'
>>previously. It is at this point, in the 'appendChild' call, that I get
>>the exception HIERARCHY_REQUEST_ERR: This node isn't allowed here.
>>What's going on here?
>>
>>
>
>Are you sure you are not trying to create two root nodes? That would be
>invalid XML. THis is OK:
>Document doc= new DocumentImpl();
>Element root = doc.createElement("person"); // Create Root Element
>Element item = doc.createElement("name"); // Create element
>root.appendChild( item ); // atach element to Root
>doc.appendChild( root ); // Add Root
>
>This gives a Hierarchy request error:
>Document doc= new DocumentImpl();
>Element item = doc.createElement("person");
>doc.appendChild( item );
>Element item = doc.createElement("name");
>doc.appendChild( item );
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Getting error HIERARCHY_REQUEST_ERR ?!?
Posted by Richard Rowell <ri...@bowmansystems.com>.
On Fri, 2003-04-11 at 08:55, Brice Ruth wrote:
> I create a 'Document' object from a DOMImplementation, then assign
> 'getDocumentElement()' to a Node object. So far, so good - no
> exceptions. I then create an Element from the Document object, using
> 'createElement' and set some attributes on the element before trying to
> append it to my 'root' Node, which I got from 'getDocumentElement()'
> previously. It is at this point, in the 'appendChild' call, that I get
> the exception HIERARCHY_REQUEST_ERR: This node isn't allowed here.
> What's going on here?
Are you sure you are not trying to create two root nodes? That would be
invalid XML. THis is OK:
Document doc= new DocumentImpl();
Element root = doc.createElement("person"); // Create Root Element
Element item = doc.createElement("name"); // Create element
root.appendChild( item ); // atach element to Root
doc.appendChild( root ); // Add Root
This gives a Hierarchy request error:
Document doc= new DocumentImpl();
Element item = doc.createElement("person");
doc.appendChild( item );
Element item = doc.createElement("name");
doc.appendChild( item );
--
Richard Rowell <ri...@bowmansystems.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Getting error HIERARCHY_REQUEST_ERR ?!?
Posted by Joseph Kesselman <ke...@us.ibm.com>.
DOM error meaning "that node isn't allowed to be the child of this node."
(The DOM enforces some -- not all -- well-formedness constraints.)
Make sure you're appending the new Element to the root element, not to the
Document node.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"may'ron DaroQbe'chugh vaj bIrIQbej" ("Put down the squeezebox and nobody
gets hurt.")