Hello,

First, sorry for my english ;)

I would like to add new svg content in a batik SVGDocument.

For exemple:
I have a document with:
-----------------------------CODE-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:ev="http://www.w3.org/2001/xml-events"; 
contentScriptType="text/ecmascript" width="824" zoomAndPan="magnify" 
contentStyleType="text/css" viewBox=" -1003 -3785 14782 7605" height="424" 
preserveAspectRatio="xMaxYMax meet" version="1.1">
<g id="1" transform="matrix(1 0 0 -1 0 0)">
<g id="101">
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-50 -11, 50 -11"/>
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-50 -2, -50 -11"/>
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-48 -2, -50 -2"/>
</g>
*****
</g>
</svg>
--------------------------------------------------------------

And I want to add this in place of the "*****":

-----------------------------CODE-----------------------------
<g id="102">
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-450 -141, 550 
-34"/>
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-348 -32, -99 
-4"/>
</g>
--------------------------------------------------------------


THIS WORKS WELL:

-----------------------------CODE-----------------------------
System.out.println("Document A");
String fichier1 ="c:\\mapsBasicAnd101.svg";
...
Document a = db.parse(is1);

System.out.println("Document B");
String fichier2 ="c:\\maps102.svg";
...
Document b = db.parse(is2);

Element a1 = (Element)a.getDocumentElement().getFirstChild();
Element b1 = (Element)b.getDocumentElement();

a1.appendChild(a.importNode(b1, true));

Source source = new DOMSource(a);

Result resultat = new StreamResult("c:\\mapsfinal.svg");
...
transformer.transform(source, resultat);
--------------------------------------------------------------

But I need to change that. The document "a" (basic) must be the document object 
of my batik software:
-----------------------------CODE-----------------------------
Document a = svgCanvas.getSVGDocument();
--------------------------------------------------------------

But it doesent work if I use it when 
-----------------------------CODE-----------------------------
Element a1 = (Element)a.getDocumentElement().getFirstChild();
// java.lang.ClassCastException: org.apache.batik.dom.GenericText
--------------------------------------------------------------

This line works:
-----------------------------CODE-----------------------------
Element root = (Element)a.getDocumentElement(); //root has tag name: "svg"
--------------------------------------------------------------

But
-----------------------------CODE-----------------------------
Node a1 = root.getFirstChild();
System.out.println(a1.getChildNodes().getLength()); //=>0
--------------------------------------------------------------

I don't understand why he gaves me 0...Element <g id="1" ...> has a more than 0 
node! 


When I save de document "a" in a file I have:

-----------------------------CODE-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:ev="http://www.w3.org/2001/xml-events"; 
contentScriptType="text/ecmascript" width="824" zoomAndPan="magnify" 
contentStyleType="text/css" viewBox=" -1003 -3785 14782 7605" height="424" 
preserveAspectRatio="xMaxYMax meet" version="1.1">
<g id="1" transform="matrix(1 0 0 -1 0 0)">
<g id="101">
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-50 -11, 50 -11"/>
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-50 -2, -50 -11"/>
<polyline style="fill:none; stroke:rgb(255,000,000);" points="-48 -2, -50 -2"/>
</g>
</g>
</svg>
--------------------------------------------------------------

I don't understand why "Element a1 = 
(Element)a.getDocumentElement().getFirstChild();" doesn't work when I use a 
Batik SVGDocument in place of a simple Document...

--
This message was sent on behalf of [EMAIL PROTECTED] at openSubscriber.com
http://www.opensubscriber.com/messages/[email protected]/topic.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to