xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Declan Shanaghy" <dshana...@w5networks.com>
Subject RE: Transcode / clone part of an SVG document
Date Tue, 07 Oct 2008 21:01:00 GMT
You need to call document.importNode(otherElement, true);
In this way the element is cloned and becomes owned by the new document.
However you still need to call node.appendChild for the previously 
imported node to become part of the DOM.


Another approach would be to use a single document and hide the elements
you do not wish to render. Either by setting the visibility attr or the
display attr.



-----Original Message-----
From: Gerrit . [mailto:g99k@hotmail.com] 
Sent: Tuesday, October 07, 2008 1:50 PM
To: batik-users@xmlgraphics.apache.org
Subject: Transcode / clone part of an SVG document


Hi, I am trying to use the package org.apache.batik.transcoder.image to
generate images of only parts of an SVG document (specific elements and
their sub-trees). These images will then be used for Eclipse GEF/GMF
figures.

I haven't found any TranscoderInput that takes an Element or a
GraphicsNode as an input, so I'm currently trying to clone Elements, and
then insert them into a new SVG document.

However, this doesn't seem possible as I get error messages that the
cloned element is from the wrong document. Apparently, the clone that is
created with cloneNode inherits the owner document from the original
element. adoptNode is not implemented in SVGOMDocument, and importNode
seems to have no effect.

What's the right way to clone an SVG element and attach it to another
document then? Are there maybe better ways to transcode parts of a
document?

Any input would be much appreciated.
Thanks in advance,
Gerrit


Element clone = (Element) elementFromDoc1.cloneNode( true );
// doc2.adoptNode( clone );
// doc2.importNode( clone, true );
doc2.getDocumentElement().appendChild( clone );

org.w3c.dom.DOMException: node.from.wrong.document
at org.apache.batik.dom.AbstractNode.createDOMException
at org.apache.batik.dom.AbstractParentNode.checkAndRemove
at org.apache.batik.dom.AbstractParentNode.appendChild



_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it
now!
http://www.live.com/getstarted.aspx
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


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


Mime
View raw message