So try this:

The String "newLayer":
----------------------------------------------------------------
<g id="101" xmlns="http://www.w3.org/2000/svg";>
<polyline points="8325 2232, 8325 2540" style="fill:none; 
stroke:rgb(255,000,000);"/>
<polyline points="7925 2232, 7925 2540" style="fill:none; 
stroke:rgb(255,000,000);"/>
...
</g>



The parsing
----------------------------------------------------------------
InputSource is2 = new InputSource(new StringReader(newLayer));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document newDocument = db.parse(is2);

//document is the Document from the Jsvgcanvas
Element root = (Element)document.getDocumentElement();

//a1 is the child of the "svg" tag. It's a kind of root element
Node a1 = document.getElementById("1");
        
//it's the <g id="101"> element
Element rootNewDocument = (Element)newDocument.getDocumentElement();

//give me: Element:g Namespace:null
System.out.println("Element:" + rootNewDocument.getTagName() + " Namespace:" + 
rootNewDocument.getNamespaceURI());

//add the new elements to the document of the jsvgcanvas
a1.appendChild(document.importNode(rootNewDocument, true));

svgCanvas.setSVGDocument((SVGDocument)document);


The document when I serialize it
----------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<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=" -3594 -4998 18402 9790" height="438" 
preserveAspectRatio="xMaxYMax meet" version="1.1">
        <g id="1" transform="matrix(1 0 0 -1 0 0)">
                <g id="105">
                        <polyline style="fill:none; stroke:rgb(255,000,000);" 
points="5078 802, 5078 30"/>
                        <polyline style="fill:none; stroke:rgb(255,000,000);" 
points="5070 802, 4665 802"/>
                        <polyline style="fill:none; stroke:rgb(255,000,000);" 
points="4230 802, 4635 802"/>
                        ...
                </g>
                <g id="101">
                        <polyline style="fill:none; stroke:rgb(255,000,000);" 
points="8325 2232, 8325 2540"/>
                        <polyline style="fill:none; stroke:rgb(255,000,000);" 
points="7925 2232, 7925 2540"/>
                        <polyline style="fill:none; stroke:rgb(255,000,000);" 
points="7525 2232, 7525 2540"/>
                        ...
                </g>
        </g>
</svg>


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


So, with this line, smth is wrong the namespace:

Element rootNewDocument = (Element)newDocument.getDocumentElement();

//give me: Element:g Namespace:null
System.out.println("Element:" + rootNewDocument.getTagName() + " Namespace:" + 
rootNewDocument.getNamespaceURI());

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

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

Reply via email to