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 Alex Speed <al...@luckymonkey.co.uk> on 2002/02/24 22:44:15 UTC

org.w3c.dom.DOMException: DOM005 Wrong document

I am not sure if anybody here can help, but basically, the problem is that I
need to merge two different Documents together, but when i try and do it, I
get this error :
 - org.w3c.dom.DOMException: DOM005 Wrong document

I am not sure of the correct procedure for doing this (I am using Xerces-J).
Basically, there is a method which creates a Document, and then another
Document. I then create an element in another document and do
element.appendChild(Document) for the other documents I created.

This generates the error above! - Am I supposed to use the same Document to
generate all 3 documents?? or use different ones? eek!

Thanks for any help!!

Alex



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: org.w3c.dom.DOMException: DOM005 Wrong document

Posted by Cliff Rowley <cl...@onsea.net>.
I cant really comment because I have no idea what you're actually doing .. 
I rarely do any UI programming, but as I recall getContentPane() is a 
method implemented by many Swing components - but obviously in your case 
getContentPane() may be your own method.  You should ensure that the method 
is returning a valid Node (or subclass of).

At 12:25 25/02/2002 +0000, you wrote:

>Ahh, I see, cheers for that :D - I have got rid of the DOM005 error, and
>have got a null pointer exception in appendChild(..) instead... oh well :)
>
>
>----- Original Message -----
>From: "Cliff Rowley" <cl...@onsea.net>
>To: <xe...@xml.apache.org>
>Sent: Monday, February 25, 2002 12:11 PM
>Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
>
>
> > At 11:57 25/02/2002 +0000, you wrote:
> >
> > >Ok, I still don't quite understand :( - say I have this code :
> > >
> > >Document doc=util.getDocument();
> > >Element root_element=doc.createElement("page");
> > >root_element.appendChild(getContentPane(...));
> > >root_element.appendChild(getContentPane(...));
> > >doc.appendChild(root_element);
> >
> > In this case, you would need to do this:
> >
> > Document doc = util.getDocument();
> > Element root_element = doc.createElement( "page" );
> >
> > But you cant just append a node from another document, you have to import
> > it first, so you do this:
> >
> > Node tmp = doc.importNode( getContentPane(...), true );
> >
> > And now we can append tmp - which is a copy of the node you want - but
> > associated with the new document:
> >
> > root_element.appendChild( tmp );
> >
> > And do the same for each document you want to merge
> >
> >
> > >where getContentPane(...) takes doc to create the Node which it returns.
> > >Urg, this is making my brain ache. I expect that the answer is very
>simple,
> > >but I am feeling to thick at the moment to see it....
> > >
> > >----- Original Message -----
> > >From: "Cliff Rowley" <cl...@onsea.net>
> > >To: <xe...@xml.apache.org>
> > >Sent: Sunday, February 24, 2002 10:42 PM
> > >Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> > >
> > >
> > > > Hey there .. its actually a pretty simple procedure...
> > > >
> > > > Basically you need to associate the node with the new document before
>it
> > > > can be appended to it:
> > > >
> > > > Node newNode = toDoc.importNode( fromElement, true );
> > > >
> > > > (newNode is identical to fromElement, but is associated with toDoc)
> > > >
> > > > toElement.appendChild( newNode );
> > > >
> > > > At 21:44 24/02/2002 +0000, you wrote:
> > > >
> > > > >I am not sure if anybody here can help, but basically, the problem is
> > >that I
> > > > >need to merge two different Documents together, but when i try and do
>it,
> > >I
> > > > >get this error :
> > > > >  - org.w3c.dom.DOMException: DOM005 Wrong document
> > > > >
> > > > >I am not sure of the correct procedure for doing this (I am using
> > >Xerces-J).
> > > > >Basically, there is a method which creates a Document, and then
>another
> > > > >Document. I then create an element in another document and do
> > > > >element.appendChild(Document) for the other documents I created.
> > > > >
> > > > >This generates the error above! - Am I supposed to use the same
>Document
> > >to
> > > > >generate all 3 documents?? or use different ones? eek!
> > > > >
> > > > >Thanks for any help!!
> > > > >
> > > > >Alex
> > > > >
> > > > >
> > > > >
> > > > >---------------------------------------------------------------------
> > > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >---
> > > > >Incoming mail is certified Virus Free.
> > > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > >
> > > >
> > > > Cliff Rowley
> > > >
> > > > Tel:            +44 (0) 1206 514263
> > > > Email:          cliff@onsea.net
> > > > Web:            http://www.onsea.net
> > > >
> > >
> > >
> >
> >---------------------------------------------------------------------------
>-
> > >----
> > >
> > >
> > > >
> > > > ---
> > > > Outgoing mail is certified Virus Free.
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > >
> > > >
> > >
> > >
> >
> >---------------------------------------------------------------------------
>-
> > >----
> > >
> > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> > >
> > >
> > >---
> > >Incoming mail is certified Virus Free.
> > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> >
> >
> > Cliff Rowley
> >
> > Tel:            +44 (0) 1206 514263
> > Email:          cliff@onsea.net
> > Web:            http://www.onsea.net
> >
>
>
>----------------------------------------------------------------------------
>----
>
>
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> >
> >
>
>
>----------------------------------------------------------------------------
>----
>
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002


Cliff Rowley

Tel:            +44 (0) 1206 514263
Email:          cliff@onsea.net
Web:            http://www.onsea.net

Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Cliff Rowley <cl...@onsea.net>.
Hehe, no problem.  I've got the dreaded lergie myself :(  Its not 
particularly nice is it?  This is day 4 or snot, coughs and other nasty 
unmentionables.

Good luck :)

At 12:56 25/02/2002 +0000, you wrote:

>Ah-ha, cracked it :D - you can't pass the same document down to create the
>getContentPane(..) document - I suppose that makes sense (if only my head
>wasn't full of cold and snot....)
>
>Thanks for the help!!
>
>----- Original Message -----
>From: "Alex Speed" <al...@luckymonkey.co.uk>
>To: <xe...@xml.apache.org>
>Sent: Monday, February 25, 2002 12:49 PM
>Subject: Re: importNode nullpointerexception (was org.w3c.dom.DOMException:
>DOM005 Wrong document)
>
>
> > Thats still creating a DOM006 Hierarchy request error
> >
> > >
> > > Should that not be:
> > >
> > > Element root_element=doc.createElement("page");
> > >
> > > Document content_doc=getContentPane(...);
> > > Element content_doc_root=content_doc.getDocumentElement();
> > >
> > > Node new_node=doc.importNode(content_doc_root,true);
> > > root_element.appendChild(new_node);
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002


Cliff Rowley

Tel:            +44 (0) 1206 514263
Email:          cliff@onsea.net
Web:            http://www.onsea.net

Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Alex Speed <al...@luckymonkey.co.uk>.
Ah-ha, cracked it :D - you can't pass the same document down to create the
getContentPane(..) document - I suppose that makes sense (if only my head
wasn't full of cold and snot....)

Thanks for the help!!

----- Original Message -----
From: "Alex Speed" <al...@luckymonkey.co.uk>
To: <xe...@xml.apache.org>
Sent: Monday, February 25, 2002 12:49 PM
Subject: Re: importNode nullpointerexception (was org.w3c.dom.DOMException:
DOM005 Wrong document)


> Thats still creating a DOM006 Hierarchy request error
>
> >
> > Should that not be:
> >
> > Element root_element=doc.createElement("page");
> >
> > Document content_doc=getContentPane(...);
> > Element content_doc_root=content_doc.getDocumentElement();
> >
> > Node new_node=doc.importNode(content_doc_root,true);
> > root_element.appendChild(new_node);
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Cliff Rowley <cl...@onsea.net>.
Err .. as far as I'm aware that should work .. is anyone else awake to 
sanity check that?  I'm not saying I'm insane - just slightly unstable .. 
*dribble*

At 12:49 25/02/2002 +0000, you wrote:

>Thats still creating a DOM006 Hierarchy request error
>
> >
> > Should that not be:
> >
> > Element root_element=doc.createElement("page");
> >
> > Document content_doc=getContentPane(...);
> > Element content_doc_root=content_doc.getDocumentElement();
> >
> > Node new_node=doc.importNode(content_doc_root,true);
> > root_element.appendChild(new_node);
> >
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002


Cliff Rowley

Tel:            +44 (0) 1206 514263
Email:          cliff@onsea.net
Web:            http://www.onsea.net

Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Alex Speed <al...@luckymonkey.co.uk>.
Thats still creating a DOM006 Hierarchy request error

> 
> Should that not be:
> 
> Element root_element=doc.createElement("page");
> 
> Document content_doc=getContentPane(...);
> Element content_doc_root=content_doc.getDocumentElement();
> 
> Node new_node=doc.importNode(content_doc_root,true);
> root_element.appendChild(new_node);
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Cliff Rowley <cl...@onsea.net>.
At 12:40 25/02/2002 +0000, you wrote:

>Document doc=util.getDocument();
>
>Element root_element=doc.createElement("page");
>Document content_doc=getContentPane(...);
>Node new_node=doc.importNode(content_doc,true);
>root_element.appendChild(new_node);

Should that not be:

Element root_element=doc.createElement("page");

Document content_doc=getContentPane(...);
Element content_doc_root=content_doc.getDocumentElement();

Node new_node=doc.importNode(content_doc_root,true);
root_element.appendChild(new_node);

>getContentPane is a method in my classes, and is returning a valid node
>(having just looked through it in Forte debugger). (Its not actually a UI
>method, its generating XML from a database)
>
>doc.importNode(...) is causing the NullPointerException, but I can't see
>why, because all of the objects are instantiated, and content_doc (the
>document returned by getContentPane) is a real document.
>I have tried casting content_doc to (Node)content_doc , but that doesn't
>make any difference.
>
>----- Original Message -----
>From: "Alex Speed" <al...@luckymonkey.co.uk>
>To: <xe...@xml.apache.org>
>Sent: Monday, February 25, 2002 12:25 PM
>Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
>
>
> > Ahh, I see, cheers for that :D - I have got rid of the DOM005 error, and
> > have got a null pointer exception in appendChild(..) instead... oh well :)
> >
> >
> > ----- Original Message -----
> > From: "Cliff Rowley" <cl...@onsea.net>
> > To: <xe...@xml.apache.org>
> > Sent: Monday, February 25, 2002 12:11 PM
> > Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> >
> >
> > > At 11:57 25/02/2002 +0000, you wrote:
> > >
> > > >Ok, I still don't quite understand :( - say I have this code :
> > > >
> > > >Document doc=util.getDocument();
> > > >Element root_element=doc.createElement("page");
> > > >root_element.appendChild(getContentPane(...));
> > > >root_element.appendChild(getContentPane(...));
> > > >doc.appendChild(root_element);
> > >
> > > In this case, you would need to do this:
> > >
> > > Document doc = util.getDocument();
> > > Element root_element = doc.createElement( "page" );
> > >
> > > But you cant just append a node from another document, you have to
>import
> > > it first, so you do this:
> > >
> > > Node tmp = doc.importNode( getContentPane(...), true );
> > >
> > > And now we can append tmp - which is a copy of the node you want - but
> > > associated with the new document:
> > >
> > > root_element.appendChild( tmp );
> > >
> > > And do the same for each document you want to merge
> > >
> > >
> > > >where getContentPane(...) takes doc to create the Node which it
>returns.
> > > >Urg, this is making my brain ache. I expect that the answer is very
> > simple,
> > > >but I am feeling to thick at the moment to see it....
> > > >
> > > >----- Original Message -----
> > > >From: "Cliff Rowley" <cl...@onsea.net>
> > > >To: <xe...@xml.apache.org>
> > > >Sent: Sunday, February 24, 2002 10:42 PM
> > > >Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> > > >
> > > >
> > > > > Hey there .. its actually a pretty simple procedure...
> > > > >
> > > > > Basically you need to associate the node with the new document
>before
> > it
> > > > > can be appended to it:
> > > > >
> > > > > Node newNode = toDoc.importNode( fromElement, true );
> > > > >
> > > > > (newNode is identical to fromElement, but is associated with toDoc)
> > > > >
> > > > > toElement.appendChild( newNode );
> > > > >
> > > > > At 21:44 24/02/2002 +0000, you wrote:
> > > > >
> > > > > >I am not sure if anybody here can help, but basically, the problem
>is
> > > >that I
> > > > > >need to merge two different Documents together, but when i try and
>do
> > it,
> > > >I
> > > > > >get this error :
> > > > > >  - org.w3c.dom.DOMException: DOM005 Wrong document
> > > > > >
> > > > > >I am not sure of the correct procedure for doing this (I am using
> > > >Xerces-J).
> > > > > >Basically, there is a method which creates a Document, and then
> > another
> > > > > >Document. I then create an element in another document and do
> > > > > >element.appendChild(Document) for the other documents I created.
> > > > > >
> > > > > >This generates the error above! - Am I supposed to use the same
> > Document
> > > >to
> > > > > >generate all 3 documents?? or use different ones? eek!
> > > > > >
> > > > > >Thanks for any help!!
> > > > > >
> > > > > >Alex
> > > > > >
> > > > > >
> > > > > >
> > > > >
> >---------------------------------------------------------------------
> > > > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >---
> > > > > >Incoming mail is certified Virus Free.
> > > > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > > >
> > > > >
> > > > > Cliff Rowley
> > > > >
> > > > > Tel:            +44 (0) 1206 514263
> > > > > Email:          cliff@onsea.net
> > > > > Web:            http://www.onsea.net
> > > > >
> > > >
> > > >
> > >
> >
> >---------------------------------------------------------------------------
> > -
> > > >----
> > > >
> > > >
> > > > >
> > > > > ---
> > > > > Outgoing mail is certified Virus Free.
> > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >---------------------------------------------------------------------------
> > -
> > > >----
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > >
> > > >
> > > >
> > > >
> > > >---
> > > >Incoming mail is certified Virus Free.
> > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > >
> > >
> > > Cliff Rowley
> > >
> > > Tel:            +44 (0) 1206 514263
> > > Email:          cliff@onsea.net
> > > Web:            http://www.onsea.net
> > >
> >
> >
> > --------------------------------------------------------------------------
>--
> > ----
> >
> >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > >
> > >
> >
> >
> > --------------------------------------------------------------------------
>--
> > ----
> >
> >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002


Cliff Rowley

Tel:            +44 (0) 1206 514263
Email:          cliff@onsea.net
Web:            http://www.onsea.net

Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Cliff Rowley <cl...@onsea.net>.
At 12:45 25/02/2002 +0000, you wrote:

>I have also tried to get the root node from the content_doc by doing
>content_doc.getFirstChild() but this creates an Exception in thread "main"
>org.w3c.dom.DOMException: DOM006 Hierarchy request er
>ror

That kinda makes sense.  The document is a container for the root element 
and all its children (and other document specific things).  You manipulate 
the document content from the document element, not the document itself.


>.....
>
>----- Original Message -----
>From: "Alex Speed" <al...@luckymonkey.co.uk>
>To: <xe...@xml.apache.org>
>Sent: Monday, February 25, 2002 12:40 PM
>Subject: Re: importNode nullpointerexception (was org.w3c.dom.DOMException:
>DOM005 Wrong document)
>
>
> > Document doc=util.getDocument();
> >
> > Element root_element=doc.createElement("page");
> > Document content_doc=getContentPane(...);
> > Node new_node=doc.importNode(content_doc,true);
> > root_element.appendChild(new_node);
> >
> > getContentPane is a method in my classes, and is returning a valid node
> > (having just looked through it in Forte debugger). (Its not actually a UI
> > method, its generating XML from a database)
> >
> > doc.importNode(...) is causing the NullPointerException, but I can't see
> > why, because all of the objects are instantiated, and content_doc (the
> > document returned by getContentPane) is a real document.
> > I have tried casting content_doc to (Node)content_doc , but that doesn't
> > make any difference.
> >
> > ----- Original Message -----
> > From: "Alex Speed" <al...@luckymonkey.co.uk>
> > To: <xe...@xml.apache.org>
> > Sent: Monday, February 25, 2002 12:25 PM
> > Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> >
> >
> > > Ahh, I see, cheers for that :D - I have got rid of the DOM005 error, and
> > > have got a null pointer exception in appendChild(..) instead... oh well
>:)
> > >
> > >
> > > ----- Original Message -----
> > > From: "Cliff Rowley" <cl...@onsea.net>
> > > To: <xe...@xml.apache.org>
> > > Sent: Monday, February 25, 2002 12:11 PM
> > > Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> > >
> > >
> > > > At 11:57 25/02/2002 +0000, you wrote:
> > > >
> > > > >Ok, I still don't quite understand :( - say I have this code :
> > > > >
> > > > >Document doc=util.getDocument();
> > > > >Element root_element=doc.createElement("page");
> > > > >root_element.appendChild(getContentPane(...));
> > > > >root_element.appendChild(getContentPane(...));
> > > > >doc.appendChild(root_element);
> > > >
> > > > In this case, you would need to do this:
> > > >
> > > > Document doc = util.getDocument();
> > > > Element root_element = doc.createElement( "page" );
> > > >
> > > > But you cant just append a node from another document, you have to
> > import
> > > > it first, so you do this:
> > > >
> > > > Node tmp = doc.importNode( getContentPane(...), true );
> > > >
> > > > And now we can append tmp - which is a copy of the node you want - but
> > > > associated with the new document:
> > > >
> > > > root_element.appendChild( tmp );
> > > >
> > > > And do the same for each document you want to merge
> > > >
> > > >
> > > > >where getContentPane(...) takes doc to create the Node which it
> > returns.
> > > > >Urg, this is making my brain ache. I expect that the answer is very
> > > simple,
> > > > >but I am feeling to thick at the moment to see it....
> > > > >
> > > > >----- Original Message -----
> > > > >From: "Cliff Rowley" <cl...@onsea.net>
> > > > >To: <xe...@xml.apache.org>
> > > > >Sent: Sunday, February 24, 2002 10:42 PM
> > > > >Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> > > > >
> > > > >
> > > > > > Hey there .. its actually a pretty simple procedure...
> > > > > >
> > > > > > Basically you need to associate the node with the new document
> > before
> > > it
> > > > > > can be appended to it:
> > > > > >
> > > > > > Node newNode = toDoc.importNode( fromElement, true );
> > > > > >
> > > > > > (newNode is identical to fromElement, but is associated with
>toDoc)
> > > > > >
> > > > > > toElement.appendChild( newNode );
> > > > > >
> > > > > > At 21:44 24/02/2002 +0000, you wrote:
> > > > > >
> > > > > > >I am not sure if anybody here can help, but basically, the
>problem
> > is
> > > > >that I
> > > > > > >need to merge two different Documents together, but when i try
>and
> > do
> > > it,
> > > > >I
> > > > > > >get this error :
> > > > > > >  - org.w3c.dom.DOMException: DOM005 Wrong document
> > > > > > >
> > > > > > >I am not sure of the correct procedure for doing this (I am using
> > > > >Xerces-J).
> > > > > > >Basically, there is a method which creates a Document, and then
> > > another
> > > > > > >Document. I then create an element in another document and do
> > > > > > >element.appendChild(Document) for the other documents I created.
> > > > > > >
> > > > > > >This generates the error above! - Am I supposed to use the same
> > > Document
> > > > >to
> > > > > > >generate all 3 documents?? or use different ones? eek!
> > > > > > >
> > > > > > >Thanks for any help!!
> > > > > > >
> > > > > > >Alex
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > >---------------------------------------------------------------------
> > > > > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > > > >For additional commands, e-mail:
>xerces-j-user-help@xml.apache.org
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >---
> > > > > > >Incoming mail is certified Virus Free.
> > > > > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > > > >
> > > > > >
> > > > > > Cliff Rowley
> > > > > >
> > > > > > Tel:            +44 (0) 1206 514263
> > > > > > Email:          cliff@onsea.net
> > > > > > Web:            http://www.onsea.net
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> >---------------------------------------------------------------------------
> > > -
> > > > >----
> > > > >
> > > > >
> > > > > >
> > > > > > ---
> > > > > > Outgoing mail is certified Virus Free.
> > > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> >---------------------------------------------------------------------------
> > > -
> > > > >----
> > > > >
> > > > >
> > > > >
> > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > > >
> > > > >
> > > > >---------------------------------------------------------------------
> > > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >---
> > > > >Incoming mail is certified Virus Free.
> > > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > >
> > > >
> > > > Cliff Rowley
> > > >
> > > > Tel:            +44 (0) 1206 514263
> > > > Email:          cliff@onsea.net
> > > > Web:            http://www.onsea.net
> > > >
> > >
> > >
> >
> > --------------------------------------------------------------------------
> > --
> > > ----
> > >
> > >
> > > >
> > > > ---
> > > > Outgoing mail is certified Virus Free.
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > >
> > > >
> > >
> > >
> >
> > --------------------------------------------------------------------------
> > --
> > > ----
> > >
> > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002


Cliff Rowley

Tel:            +44 (0) 1206 514263
Email:          cliff@onsea.net
Web:            http://www.onsea.net

Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Alex Speed <al...@luckymonkey.co.uk>.
I have also tried to get the root node from the content_doc by doing
content_doc.getFirstChild() but this creates an Exception in thread "main"
org.w3c.dom.DOMException: DOM006 Hierarchy request er
ror

.....

----- Original Message -----
From: "Alex Speed" <al...@luckymonkey.co.uk>
To: <xe...@xml.apache.org>
Sent: Monday, February 25, 2002 12:40 PM
Subject: Re: importNode nullpointerexception (was org.w3c.dom.DOMException:
DOM005 Wrong document)


> Document doc=util.getDocument();
>
> Element root_element=doc.createElement("page");
> Document content_doc=getContentPane(...);
> Node new_node=doc.importNode(content_doc,true);
> root_element.appendChild(new_node);
>
> getContentPane is a method in my classes, and is returning a valid node
> (having just looked through it in Forte debugger). (Its not actually a UI
> method, its generating XML from a database)
>
> doc.importNode(...) is causing the NullPointerException, but I can't see
> why, because all of the objects are instantiated, and content_doc (the
> document returned by getContentPane) is a real document.
> I have tried casting content_doc to (Node)content_doc , but that doesn't
> make any difference.
>
> ----- Original Message -----
> From: "Alex Speed" <al...@luckymonkey.co.uk>
> To: <xe...@xml.apache.org>
> Sent: Monday, February 25, 2002 12:25 PM
> Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
>
>
> > Ahh, I see, cheers for that :D - I have got rid of the DOM005 error, and
> > have got a null pointer exception in appendChild(..) instead... oh well
:)
> >
> >
> > ----- Original Message -----
> > From: "Cliff Rowley" <cl...@onsea.net>
> > To: <xe...@xml.apache.org>
> > Sent: Monday, February 25, 2002 12:11 PM
> > Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> >
> >
> > > At 11:57 25/02/2002 +0000, you wrote:
> > >
> > > >Ok, I still don't quite understand :( - say I have this code :
> > > >
> > > >Document doc=util.getDocument();
> > > >Element root_element=doc.createElement("page");
> > > >root_element.appendChild(getContentPane(...));
> > > >root_element.appendChild(getContentPane(...));
> > > >doc.appendChild(root_element);
> > >
> > > In this case, you would need to do this:
> > >
> > > Document doc = util.getDocument();
> > > Element root_element = doc.createElement( "page" );
> > >
> > > But you cant just append a node from another document, you have to
> import
> > > it first, so you do this:
> > >
> > > Node tmp = doc.importNode( getContentPane(...), true );
> > >
> > > And now we can append tmp - which is a copy of the node you want - but
> > > associated with the new document:
> > >
> > > root_element.appendChild( tmp );
> > >
> > > And do the same for each document you want to merge
> > >
> > >
> > > >where getContentPane(...) takes doc to create the Node which it
> returns.
> > > >Urg, this is making my brain ache. I expect that the answer is very
> > simple,
> > > >but I am feeling to thick at the moment to see it....
> > > >
> > > >----- Original Message -----
> > > >From: "Cliff Rowley" <cl...@onsea.net>
> > > >To: <xe...@xml.apache.org>
> > > >Sent: Sunday, February 24, 2002 10:42 PM
> > > >Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> > > >
> > > >
> > > > > Hey there .. its actually a pretty simple procedure...
> > > > >
> > > > > Basically you need to associate the node with the new document
> before
> > it
> > > > > can be appended to it:
> > > > >
> > > > > Node newNode = toDoc.importNode( fromElement, true );
> > > > >
> > > > > (newNode is identical to fromElement, but is associated with
toDoc)
> > > > >
> > > > > toElement.appendChild( newNode );
> > > > >
> > > > > At 21:44 24/02/2002 +0000, you wrote:
> > > > >
> > > > > >I am not sure if anybody here can help, but basically, the
problem
> is
> > > >that I
> > > > > >need to merge two different Documents together, but when i try
and
> do
> > it,
> > > >I
> > > > > >get this error :
> > > > > >  - org.w3c.dom.DOMException: DOM005 Wrong document
> > > > > >
> > > > > >I am not sure of the correct procedure for doing this (I am using
> > > >Xerces-J).
> > > > > >Basically, there is a method which creates a Document, and then
> > another
> > > > > >Document. I then create an element in another document and do
> > > > > >element.appendChild(Document) for the other documents I created.
> > > > > >
> > > > > >This generates the error above! - Am I supposed to use the same
> > Document
> > > >to
> > > > > >generate all 3 documents?? or use different ones? eek!
> > > > > >
> > > > > >Thanks for any help!!
> > > > > >
> > > > > >Alex
> > > > > >
> > > > > >
> > > > > >
> > > > >
> >---------------------------------------------------------------------
> > > > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > > >For additional commands, e-mail:
xerces-j-user-help@xml.apache.org
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >---
> > > > > >Incoming mail is certified Virus Free.
> > > > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > > >
> > > > >
> > > > > Cliff Rowley
> > > > >
> > > > > Tel:            +44 (0) 1206 514263
> > > > > Email:          cliff@onsea.net
> > > > > Web:            http://www.onsea.net
> > > > >
> > > >
> > > >
> > >
> >
>
>---------------------------------------------------------------------------
> > -
> > > >----
> > > >
> > > >
> > > > >
> > > > > ---
> > > > > Outgoing mail is certified Virus Free.
> > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
>
>---------------------------------------------------------------------------
> > -
> > > >----
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > >
> > > >
> > > >
> > > >
> > > >---
> > > >Incoming mail is certified Virus Free.
> > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > >
> > >
> > > Cliff Rowley
> > >
> > > Tel:            +44 (0) 1206 514263
> > > Email:          cliff@onsea.net
> > > Web:            http://www.onsea.net
> > >
> >
> >
>
> --------------------------------------------------------------------------
> --
> > ----
> >
> >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > >
> > >
> >
> >
>
> --------------------------------------------------------------------------
> --
> > ----
> >
> >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: importNode nullpointerexception (was org.w3c.dom.DOMException: DOM005 Wrong document)

Posted by Alex Speed <al...@luckymonkey.co.uk>.
Document doc=util.getDocument();

Element root_element=doc.createElement("page");
Document content_doc=getContentPane(...);
Node new_node=doc.importNode(content_doc,true);
root_element.appendChild(new_node);

getContentPane is a method in my classes, and is returning a valid node
(having just looked through it in Forte debugger). (Its not actually a UI
method, its generating XML from a database)

doc.importNode(...) is causing the NullPointerException, but I can't see
why, because all of the objects are instantiated, and content_doc (the
document returned by getContentPane) is a real document.
I have tried casting content_doc to (Node)content_doc , but that doesn't
make any difference.

----- Original Message -----
From: "Alex Speed" <al...@luckymonkey.co.uk>
To: <xe...@xml.apache.org>
Sent: Monday, February 25, 2002 12:25 PM
Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document


> Ahh, I see, cheers for that :D - I have got rid of the DOM005 error, and
> have got a null pointer exception in appendChild(..) instead... oh well :)
>
>
> ----- Original Message -----
> From: "Cliff Rowley" <cl...@onsea.net>
> To: <xe...@xml.apache.org>
> Sent: Monday, February 25, 2002 12:11 PM
> Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
>
>
> > At 11:57 25/02/2002 +0000, you wrote:
> >
> > >Ok, I still don't quite understand :( - say I have this code :
> > >
> > >Document doc=util.getDocument();
> > >Element root_element=doc.createElement("page");
> > >root_element.appendChild(getContentPane(...));
> > >root_element.appendChild(getContentPane(...));
> > >doc.appendChild(root_element);
> >
> > In this case, you would need to do this:
> >
> > Document doc = util.getDocument();
> > Element root_element = doc.createElement( "page" );
> >
> > But you cant just append a node from another document, you have to
import
> > it first, so you do this:
> >
> > Node tmp = doc.importNode( getContentPane(...), true );
> >
> > And now we can append tmp - which is a copy of the node you want - but
> > associated with the new document:
> >
> > root_element.appendChild( tmp );
> >
> > And do the same for each document you want to merge
> >
> >
> > >where getContentPane(...) takes doc to create the Node which it
returns.
> > >Urg, this is making my brain ache. I expect that the answer is very
> simple,
> > >but I am feeling to thick at the moment to see it....
> > >
> > >----- Original Message -----
> > >From: "Cliff Rowley" <cl...@onsea.net>
> > >To: <xe...@xml.apache.org>
> > >Sent: Sunday, February 24, 2002 10:42 PM
> > >Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> > >
> > >
> > > > Hey there .. its actually a pretty simple procedure...
> > > >
> > > > Basically you need to associate the node with the new document
before
> it
> > > > can be appended to it:
> > > >
> > > > Node newNode = toDoc.importNode( fromElement, true );
> > > >
> > > > (newNode is identical to fromElement, but is associated with toDoc)
> > > >
> > > > toElement.appendChild( newNode );
> > > >
> > > > At 21:44 24/02/2002 +0000, you wrote:
> > > >
> > > > >I am not sure if anybody here can help, but basically, the problem
is
> > >that I
> > > > >need to merge two different Documents together, but when i try and
do
> it,
> > >I
> > > > >get this error :
> > > > >  - org.w3c.dom.DOMException: DOM005 Wrong document
> > > > >
> > > > >I am not sure of the correct procedure for doing this (I am using
> > >Xerces-J).
> > > > >Basically, there is a method which creates a Document, and then
> another
> > > > >Document. I then create an element in another document and do
> > > > >element.appendChild(Document) for the other documents I created.
> > > > >
> > > > >This generates the error above! - Am I supposed to use the same
> Document
> > >to
> > > > >generate all 3 documents?? or use different ones? eek!
> > > > >
> > > > >Thanks for any help!!
> > > > >
> > > > >Alex
> > > > >
> > > > >
> > > > >
> > > >
>---------------------------------------------------------------------
> > > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >---
> > > > >Incoming mail is certified Virus Free.
> > > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > >
> > > >
> > > > Cliff Rowley
> > > >
> > > > Tel:            +44 (0) 1206 514263
> > > > Email:          cliff@onsea.net
> > > > Web:            http://www.onsea.net
> > > >
> > >
> > >
> >
>
>---------------------------------------------------------------------------
> -
> > >----
> > >
> > >
> > > >
> > > > ---
> > > > Outgoing mail is certified Virus Free.
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > > >
> > > >
> > >
> > >
> >
>
>---------------------------------------------------------------------------
> -
> > >----
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> > >
> > >
> > >---
> > >Incoming mail is certified Virus Free.
> > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> >
> >
> > Cliff Rowley
> >
> > Tel:            +44 (0) 1206 514263
> > Email:          cliff@onsea.net
> > Web:            http://www.onsea.net
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> >
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: org.w3c.dom.DOMException: DOM005 Wrong document

Posted by Alex Speed <al...@luckymonkey.co.uk>.
Ahh, I see, cheers for that :D - I have got rid of the DOM005 error, and
have got a null pointer exception in appendChild(..) instead... oh well :)


----- Original Message -----
From: "Cliff Rowley" <cl...@onsea.net>
To: <xe...@xml.apache.org>
Sent: Monday, February 25, 2002 12:11 PM
Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document


> At 11:57 25/02/2002 +0000, you wrote:
>
> >Ok, I still don't quite understand :( - say I have this code :
> >
> >Document doc=util.getDocument();
> >Element root_element=doc.createElement("page");
> >root_element.appendChild(getContentPane(...));
> >root_element.appendChild(getContentPane(...));
> >doc.appendChild(root_element);
>
> In this case, you would need to do this:
>
> Document doc = util.getDocument();
> Element root_element = doc.createElement( "page" );
>
> But you cant just append a node from another document, you have to import
> it first, so you do this:
>
> Node tmp = doc.importNode( getContentPane(...), true );
>
> And now we can append tmp - which is a copy of the node you want - but
> associated with the new document:
>
> root_element.appendChild( tmp );
>
> And do the same for each document you want to merge
>
>
> >where getContentPane(...) takes doc to create the Node which it returns.
> >Urg, this is making my brain ache. I expect that the answer is very
simple,
> >but I am feeling to thick at the moment to see it....
> >
> >----- Original Message -----
> >From: "Cliff Rowley" <cl...@onsea.net>
> >To: <xe...@xml.apache.org>
> >Sent: Sunday, February 24, 2002 10:42 PM
> >Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
> >
> >
> > > Hey there .. its actually a pretty simple procedure...
> > >
> > > Basically you need to associate the node with the new document before
it
> > > can be appended to it:
> > >
> > > Node newNode = toDoc.importNode( fromElement, true );
> > >
> > > (newNode is identical to fromElement, but is associated with toDoc)
> > >
> > > toElement.appendChild( newNode );
> > >
> > > At 21:44 24/02/2002 +0000, you wrote:
> > >
> > > >I am not sure if anybody here can help, but basically, the problem is
> >that I
> > > >need to merge two different Documents together, but when i try and do
it,
> >I
> > > >get this error :
> > > >  - org.w3c.dom.DOMException: DOM005 Wrong document
> > > >
> > > >I am not sure of the correct procedure for doing this (I am using
> >Xerces-J).
> > > >Basically, there is a method which creates a Document, and then
another
> > > >Document. I then create an element in another document and do
> > > >element.appendChild(Document) for the other documents I created.
> > > >
> > > >This generates the error above! - Am I supposed to use the same
Document
> >to
> > > >generate all 3 documents?? or use different ones? eek!
> > > >
> > > >Thanks for any help!!
> > > >
> > > >Alex
> > > >
> > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > >
> > > >
> > > >
> > > >
> > > >---
> > > >Incoming mail is certified Virus Free.
> > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > >
> > >
> > > Cliff Rowley
> > >
> > > Tel:            +44 (0) 1206 514263
> > > Email:          cliff@onsea.net
> > > Web:            http://www.onsea.net
> > >
> >
> >
>
>---------------------------------------------------------------------------
-
> >----
> >
> >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> > >
> > >
> >
> >
>
>---------------------------------------------------------------------------
-
> >----
> >
> >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> >
> >
> >---
> >Incoming mail is certified Virus Free.
> >Checked by AVG anti-virus system (http://www.grisoft.com).
> >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
>
>
> Cliff Rowley
>
> Tel:            +44 (0) 1206 514263
> Email:          cliff@onsea.net
> Web:            http://www.onsea.net
>


----------------------------------------------------------------------------
----


>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: org.w3c.dom.DOMException: DOM005 Wrong document

Posted by Cliff Rowley <cl...@onsea.net>.
At 11:57 25/02/2002 +0000, you wrote:

>Ok, I still don't quite understand :( - say I have this code :
>
>Document doc=util.getDocument();
>Element root_element=doc.createElement("page");
>root_element.appendChild(getContentPane(...));
>root_element.appendChild(getContentPane(...));
>doc.appendChild(root_element);

In this case, you would need to do this:

Document doc = util.getDocument();
Element root_element = doc.createElement( "page" );

But you cant just append a node from another document, you have to import 
it first, so you do this:

Node tmp = doc.importNode( getContentPane(...), true );

And now we can append tmp - which is a copy of the node you want - but 
associated with the new document:

root_element.appendChild( tmp );

And do the same for each document you want to merge


>where getContentPane(...) takes doc to create the Node which it returns.
>Urg, this is making my brain ache. I expect that the answer is very simple,
>but I am feeling to thick at the moment to see it....
>
>----- Original Message -----
>From: "Cliff Rowley" <cl...@onsea.net>
>To: <xe...@xml.apache.org>
>Sent: Sunday, February 24, 2002 10:42 PM
>Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document
>
>
> > Hey there .. its actually a pretty simple procedure...
> >
> > Basically you need to associate the node with the new document before it
> > can be appended to it:
> >
> > Node newNode = toDoc.importNode( fromElement, true );
> >
> > (newNode is identical to fromElement, but is associated with toDoc)
> >
> > toElement.appendChild( newNode );
> >
> > At 21:44 24/02/2002 +0000, you wrote:
> >
> > >I am not sure if anybody here can help, but basically, the problem is
>that I
> > >need to merge two different Documents together, but when i try and do it,
>I
> > >get this error :
> > >  - org.w3c.dom.DOMException: DOM005 Wrong document
> > >
> > >I am not sure of the correct procedure for doing this (I am using
>Xerces-J).
> > >Basically, there is a method which creates a Document, and then another
> > >Document. I then create an element in another document and do
> > >element.appendChild(Document) for the other documents I created.
> > >
> > >This generates the error above! - Am I supposed to use the same Document
>to
> > >generate all 3 documents?? or use different ones? eek!
> > >
> > >Thanks for any help!!
> > >
> > >Alex
> > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> > >
> > >
> > >---
> > >Incoming mail is certified Virus Free.
> > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> >
> >
> > Cliff Rowley
> >
> > Tel:            +44 (0) 1206 514263
> > Email:          cliff@onsea.net
> > Web:            http://www.onsea.net
> >
>
>
>----------------------------------------------------------------------------
>----
>
>
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
> >
> >
>
>
>----------------------------------------------------------------------------
>----
>
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002


Cliff Rowley

Tel:            +44 (0) 1206 514263
Email:          cliff@onsea.net
Web:            http://www.onsea.net

Re: org.w3c.dom.DOMException: DOM005 Wrong document

Posted by Alex Speed <al...@luckymonkey.co.uk>.
Ok, I still don't quite understand :( - say I have this code :

Document doc=util.getDocument();
Element root_element=doc.createElement("page");
root_element.appendChild(getContentPane(...));
root_element.appendChild(getContentPane(...));
doc.appendChild(root_element);

where getContentPane(...) takes doc to create the Node which it returns.
Urg, this is making my brain ache. I expect that the answer is very simple,
but I am feeling to thick at the moment to see it....

----- Original Message -----
From: "Cliff Rowley" <cl...@onsea.net>
To: <xe...@xml.apache.org>
Sent: Sunday, February 24, 2002 10:42 PM
Subject: Re: org.w3c.dom.DOMException: DOM005 Wrong document


> Hey there .. its actually a pretty simple procedure...
>
> Basically you need to associate the node with the new document before it
> can be appended to it:
>
> Node newNode = toDoc.importNode( fromElement, true );
>
> (newNode is identical to fromElement, but is associated with toDoc)
>
> toElement.appendChild( newNode );
>
> At 21:44 24/02/2002 +0000, you wrote:
>
> >I am not sure if anybody here can help, but basically, the problem is
that I
> >need to merge two different Documents together, but when i try and do it,
I
> >get this error :
> >  - org.w3c.dom.DOMException: DOM005 Wrong document
> >
> >I am not sure of the correct procedure for doing this (I am using
Xerces-J).
> >Basically, there is a method which creates a Document, and then another
> >Document. I then create an element in another document and do
> >element.appendChild(Document) for the other documents I created.
> >
> >This generates the error above! - Am I supposed to use the same Document
to
> >generate all 3 documents?? or use different ones? eek!
> >
> >Thanks for any help!!
> >
> >Alex
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> >
> >
> >---
> >Incoming mail is certified Virus Free.
> >Checked by AVG anti-virus system (http://www.grisoft.com).
> >Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
>
>
> Cliff Rowley
>
> Tel:            +44 (0) 1206 514263
> Email:          cliff@onsea.net
> Web:            http://www.onsea.net
>


----------------------------------------------------------------------------
----


>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: org.w3c.dom.DOMException: DOM005 Wrong document

Posted by Cliff Rowley <cl...@onsea.net>.
Hey there .. its actually a pretty simple procedure...

Basically you need to associate the node with the new document before it 
can be appended to it:

Node newNode = toDoc.importNode( fromElement, true );

(newNode is identical to fromElement, but is associated with toDoc)

toElement.appendChild( newNode );

At 21:44 24/02/2002 +0000, you wrote:

>I am not sure if anybody here can help, but basically, the problem is that I
>need to merge two different Documents together, but when i try and do it, I
>get this error :
>  - org.w3c.dom.DOMException: DOM005 Wrong document
>
>I am not sure of the correct procedure for doing this (I am using Xerces-J).
>Basically, there is a method which creates a Document, and then another
>Document. I then create an element in another document and do
>element.appendChild(Document) for the other documents I created.
>
>This generates the error above! - Am I supposed to use the same Document to
>generate all 3 documents?? or use different ones? eek!
>
>Thanks for any help!!
>
>Alex
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.325 / Virus Database: 182 - Release Date: 19/02/2002


Cliff Rowley

Tel:            +44 (0) 1206 514263
Email:          cliff@onsea.net
Web:            http://www.onsea.net