xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bishop, Michael W. CONTR J9C880" <michael.bishop....@jfcom.mil>
Subject RE: adding a <g> element generates a <svg> , creating a two <svg> into a single file
Date Wed, 05 Nov 2008 15:40:53 GMT
Shouldn't that last line be:
root.appendChild(elementToinsert, true)?  Your "ele" variable is initialized to a root element
which would be the <svg> element.


From: control_batik [mailto:a20022065@pucp.edu.pe]
Sent: Wed 11/5/2008 10:20 AM
To: batik-users@xmlgraphics.apache.org
Subject: adding a <g> element generates a <svg> , creating a two <svg> into
a single file

Hi all,

I use these lines to add a <g> tag into a new <svg> tag:

final Element root = basedocument.getDocumentElement();
final Element ele = newGraphElement.getRootelement();               
elementToinsert = (Element)
elementToinsert.setAttribute("transform", "translate("  
newGraphElement.getPosX()   ","   newGraphElement.getPosY()   ")");
root.appendChild(basedocument.importNode(ele, true));

They work perfectly. I use "transform" to insert the element in a
specific location.
I save the generated svg file using DOMUtilities.writeDocument.
When I open the file with Inkscape it looks ok.

When I use the same code to insert the generated file into a empty svg file,
I saw that only one element its located correctely (I use a JSVGCanvas), and
others elements are located in the 0,0 position.

I open the generated file in a text editor, I see that  the number of svg
tags are as much as I insert a <g> tag with code before.

So, that explains why only the first inserted element is located well , the
atribute transform only moves the first svg tag in the file.

the question is, How can i insert only a <g> tag instead of a  <svg> tag?

the generated file has this structure:
<svg...><g></g> <svg...></svg></svg><svg...><g></g></svg>

I want something like this:

Thank you for your help.
View this message in context: http://www.nabble.com/adding-a-%3Cg%3E-element-generates-a-%3Csvg%3E-%2C-creating-a-two-%3Csvg%3E-into-a-single-file-tp20343192p20343192.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

View raw message