Hi,
You have two elements at the root of the document, I believe. Your
fragment is really just the same thing as your document in the case you gave,
so appending 'element' to 'frag' puts 'element' at the root of the document.
Also, it's probably an error to append a document to itself as a child
(doc.appendChild(frag) should probably always fail, given that frag is also
'doc' - not the same top level object, but the same tree).
Chris
> | frag.appendChild( element ); // add element to our fragment
> | doc.appendChild( frag ); // add the fragment to my existing
-----Original Message-----
From: Jeffery B. Rancier [mailto:[EMAIL PROTECTED]
Sent: Monday, August 04, 2003 1:02 PM
To: [EMAIL PROTECTED]
Subject: Re: DocumentFragInpl() exception : HIERARCHY_REQUEST_ERR
[EMAIL PROTECTED] writes:
I forgot, the line the exception is on is:
doc.appendChild( frag ); // add the fragment to my existing Document
Thanks,
Jeff
> I have an existing document to which I am trying to add a
> DocumentFragment to. It's failing with the following:
>
> ,----
> | org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
> insert a
> | node where it is not permitted.
> | at org.apache.xerces.dom.CoreDocumentImpl.insertBefore(Unknown
> Source)
> | at org.apache.xerces.dom.ParentNode.internalInsertBefore(Unknown
> Source)
> |
> | at org.apache.xerces.dom.ParentNode.insertBefore(Unknown Source)
> | at org.apache.xerces.dom.CoreDocumentImpl.insertBefore(Unknown
> Source)
> | at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
> `----
>
> Here's the snippet:
>
> ,----
> | public void actionPerformed( ActionEvent e )
> | {
> | DocumentFragment frag = new DocumentFragmentImpl((CoreDocumentImpl)doc
> );
> | //create fragment based on existing Document
> |
> | Element element = doc.createElement( "element" ); // create a new
> Element
> | item = doc.createElement( "component" ); // create another
> | item.appendChild( doc.createTextNode( "NUM_SHORT" )); // give it a
> TextNode
> | element.appendChild( item ); // add item to
> element
> |
> | frag.appendChild( element ); // add element to our fragment
> | doc.appendChild( frag ); // add the fragment to my existing
> Document
> | }
> `----
>
> Can anyone see where I'm going wrong?
> --
> Thanks,
> Jeff
> ,----
> | Jeffery B. Rancier
> |
> | Softechnics
> | a METTLER TOLEDO company
> `----
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Thanks,
Jeff
,----
| Jeffery B. Rancier
|
| Softechnics
| a METTLER TOLEDO company
`----
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]