Marc, I think you are using svg name space as the default name space in the SVG document you are editing. Well I was doing that and when I added some new elements using DOM methods the output was a right SVG (XML document) but batik didn't recognize the new tags, so I defined the svg name espace: xsl:svgdcs in the document.
xmlns:svgdcs="http://www.w3.org/2000/svg" set the name space in the java application: xPath.setNamespaceContext(new NamespaceContextProvider("svgdcs",SVG_NS)); and work with the namespace elements in the rest of the code: public void changeLocation(String nameLayer,XPath xPath,AbstractDocumentFragment svgFragment) throws XPathExpressionException{ Node position=(Node) xPath.evaluate("//svgdcs:[EMAIL PROTECTED]'"+nameLayer+"']",svgFragment,XPathConstants.NODE); position.getAttributes().getNamedItem("transform").setNodeValue("translate("+x+","+y+")"); } Best Regards Abraham On Oct 31, 2007 6:52 PM, Marc-Wayne M. Formales <[EMAIL PROTECTED]> wrote: > > Abraham, > > Thanks for your input. The DOM Modification flow is basically: > > 1. create Element from the SVG DOM object and set attributes > 2. navigate DOM to find specific Node > 3. clone Node > 4. navigate cloned Node and append Element to the cloned Node > 5. replace Node with cloned Node in Update Manager > > I verified that the cloned Node has the appropriate namespace, are you > suggesting that I need to declare it from the Element? And if yes, how? > > Here are some snippets of the code: > > //create Element from the SVG Document > Element animate = diagramSVG.createElement("animateColor"); //where > diagramSVG is Document type > //set attributes > animate.setAttribute( ...); > ... > > //Navigate DOM to find element to append to > ... > Node aLink = ... ; > Node animatedALink = origNode.cloneNode(true); > //Navigate clonedNode and then append "animate" to a child of the cloned > Node > ... > (child of animatedALink).appendChild((Node)animate); > > > //UpdateManager code > > > Regards, > > Marc > > > Date: Wed, 31 Oct 2007 14:14:29 +0000 > > From: [EMAIL PROTECTED] > > To: [email protected]; [EMAIL PROTECTED] > > Subject: Re: JSVGCanvas does not update with modified DOM using Update > Manager > > > > > > Hi Marc, > > > > You don't say how you are updating the SVGDOM, but I have a similar > > problem using Document Fragments. My XML file was right and worked in > > Opera browser but not in JSVGCanvas. The solution I came across was to > > declare the svg name space in the document (i.e xmlns:svg ...)and > > use it when creating the new elements (i.e svg:rect), so JSVGCanvas > > will understand that the new elements were SVG elements and not any > > other XML flavor. > > > > > > Hope it will helps > > > > > > Abraham > > > > On Oct 24, 2007 7:00 PM, Marc-Wayne M. Formales <[EMAIL PROTECTED]> wrote: > > > > > > I'm fairly new to Swing/Batik/SVG so please bear with me. > > > > > > I have a JApplet that loads an SVG via JSVGCanvas.setDocument(xmlDoc). > If > > > a user clicks on a certain part of the document (any <a> tag), then I > have > > > some code that will animate that node and replace it in the document > object. > > > I am doing this in the update manager, which does run in the > gvtRendering > > > event, but the UI is not updated with the changes I made. I know that > the > > > DOM object is correct because if I write that to the file system, the > > > changes are there. Is there something that I'm missing? > > > > > > Here is a snippet from the OnClickAction method: > > > > > > > > > NodeList aLinks = diagramSVG.getElementsByTagName("a"); > > > for (int i . . . ) { > > > final Node aLink = aLinks.item(i); > > > ..... > > > Some code to find the element that was clicked on > > > clone the element > > > append an animate node to the element > > > ..... > > > } > > > > > > UpdateManager um = BatikEWD.diaCanvas.getUpdateManager(); > > > um.getUpdateRunnableQueue().invokeLater(new Runnable() { > > > public void run() { > > > System.out.println("connID: " + connID); > > > diagramSVG.getDocumentElement().replaceChild(animatedALink, aLink); > > > //where animatedALink is the modified > > > canvas.setDocument(diagramSVG); > > > canvas.updateUI(); //I've tried repaint too but nothing seems to > > > work > > > panel.updateUI(); //I've tried repaint too but nothing seems to > > > work > > > } > > > }); > > > > > > > > > Regards, > > > > > > Marc > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
