You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by emzic <em...@embege.com> on 2008/07/15 14:27:42 UTC

org.w3c.dom.DOMException: Cannot import node. when cloning a node.

hello,

when i try to clone a the root-node from an svg file (SVGOMDocument) i get
the following exception:

org.w3c.dom.DOMException: Cannot import node.
	at org.apache.batik.dom.AbstractNode.createDOMException(Unknown Source)
	at org.apache.batik.dom.AbstractDocument.importNode(Unknown Source)
	at org.apache.batik.dom.AbstractDocument.importNode(Unknown Source)
	at org.apache.batik.dom.AbstractDocument.cloneNode(Unknown Source)

what could be the reason for this exception?

thanks!
-- 
View this message in context: http://www.nabble.com/org.w3c.dom.DOMException%3A-Cannot-import-node.-when-cloning-a-node.-tp18464020p18464020.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: JSVGCanvas, applet and mouseEvents.

Posted by Alvarez <jp...@genigraph.fr>.
Hi Thomas,

 

In the firts place I've used 'setDocumentState(ALWAYS_DYNAMIC)' but it
didn't work, so I've changed it to do some tests and completely forgot to
change it again !

Now with that my code works perfectly, thank you very much for your help,
I'm a dizzy man.

 

PS : I use circles for my points

 

  _____  

Hi Alvarez,

"Alvarez" <jp...@genigraph.fr> wrote on 07/15/2008 11:59:17 AM:

> Hello, I want to add mouseEvents to batik objects but it doesn't work !
> 
> Here is a little part of my code : 
[...] 
> This way of adding an event is ignored and I don't know why, is there
> something I do wrong ?

   The code looks fairly good.  My guess is that the 
canvas doesn't know that it needs to by dynamic. 
Do you call 'setDocumentState(ALWAYS_DYNAMIC)' on 
the canvas? 

> In fact I have a graph and a lot of points, and when the mouse is on a
point
> I what to show his name, I can do that with this :
> 
> canvas.addMouseListener(new java.awt.event.MouseAdapter(){ ... } 
> 
> because it works but I don't want to check every point one by one each
time
> the mouse move.

  Well just for the record the canvas must of course check every point one
by one 
just as you would.  It might save some time since it will skip groups where 
the bounding box of the group doesn't contain the point but assuming all of
your 
points are the children of one group this won't help any over what you might

be doing.   Also what are you using for your points?  circles?  Markers? 
Because Markers for example aren't individually 'addressable'. 


Re: JSVGCanvas, applet and mouseEvents.

Posted by th...@kodak.com.
Hi Alvarez,

"Alvarez" <jp...@genigraph.fr> wrote on 07/15/2008 11:59:17 AM:

> Hello, I want to add mouseEvents to batik objects but it doesn't work !
> 
> Here is a little part of my code : 
[...]
> This way of adding an event is ignored and I don't know why, is there
> something I do wrong ?

   The code looks fairly good.  My guess is that the
canvas doesn't know that it needs to by dynamic.
Do you call 'setDocumentState(ALWAYS_DYNAMIC)' on
the canvas?

> In fact I have a graph and a lot of points, and when the mouse is on a 
point
> I what to show his name, I can do that with this :
> 
> canvas.addMouseListener(new java.awt.event.MouseAdapter(){ ... } 
> 
> because it works but I don't want to check every point one by one each 
time
> the mouse move.

  Well just for the record the canvas must of course check every point one 
by one
just as you would.  It might save some time since it will skip groups 
where
the bounding box of the group doesn't contain the point but assuming all 
of your
points are the children of one group this won't help any over what you 
might
be doing.   Also what are you using for your points?  circles?  Markers?
Because Markers for example aren't individually 'addressable'.

JSVGCanvas, applet and mouseEvents.

Posted by Alvarez <jp...@genigraph.fr>.
Hello, I want to add mouseEvents to batik objects but it doesn't work !

Here is a little part of my code : 

		//Fond
		Element rect = doc.createElementNS(svgNS, "rect");
		rect.setAttributeNS(null, "x", "5%");
		rect.setAttributeNS(null, "y", "5%");
		rect.setAttributeNS(null, "width", "90%");
		rect.setAttributeNS(null, "height", "90%");
		rect.setAttributeNS(null, "style", "fill:#F5F5F5");
		rect.setAttributeNS(null, "stroke-width", "0.01034");
		svgRoot.appendChild(rect);

		EventTarget eventTarget = (EventTarget)rect;
		eventTarget.addEventListener("click", new EventListener(){
			public void handleEvent(org.w3c.dom.events.Event
evt) {
				org.w3c.dom.events.MouseEvent mEvt =
(org.w3c.dom.events.MouseEvent)evt;	
				System.out.println("Test clic : " +
mEvt.getButton());
		}, false);

This way of adding an event is ignored and I don't know why, is there
something I do wrong ?


In fact I have a graph and a lot of points, and when the mouse is on a point
I what to show his name, I can do that with this :

canvas.addMouseListener(new java.awt.event.MouseAdapter(){ ... } 

because it works but I don't want to check every point one by one each time
the mouse move.


Have you a solution for me ? 

Thanks.



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: org.w3c.dom.DOMException: Cannot import node. when cloning a node.

Posted by emzic <em...@embege.com>.


Helder Magalhães wrote:
> 
>> what could be the reason for this exception?
> Can you attach a reduced test case or paste a relevant code snippet?
> Guessing from exception's stack trace is somehow rude! ;-)
> 

i just solved the problem by using

DOMUtilities.deepCloneDocument(doc, doc.getImplementation());

instead of cloneNode.


thanks anyways!

-- 
View this message in context: http://www.nabble.com/org.w3c.dom.DOMException%3A-Cannot-import-node.-when-cloning-a-node.-tp18464020p18468199.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: org.w3c.dom.DOMException: Cannot import node. when cloning a node.

Posted by Helder Magalhães <he...@gmail.com>.
> what could be the reason for this exception?
Can you attach a reduced test case or paste a relevant code snippet?
Guessing from exception's stack trace is somehow rude! ;-)

Regards,

 Helder Magalhães

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: org.w3c.dom.DOMException: Cannot import node. when cloning a node.

Posted by th...@kodak.com.
Hi Emzic,

emzic <em...@embege.com> wrote on 07/15/2008 08:27:42 AM:

> when i try to clone a the root-node from an svg file (SVGOMDocument) i 
get
> the following exception:
> 
> org.w3c.dom.DOMException: Cannot import node.

   I see you found another solution to your problem.  The issue
here is that you can't import a Document node into another Document.
An DOM Document can only ever have one Document node.

   Your work around clones the document with the same DOM 
implementation but they are separate DOM documents.