Hi Thomas, thank you for your advice. I tried to comment the first 'setDocument' out, but it didn't work.
Then, I used the 'getNamespaceURI()' method as you suggested:
Element docRoot = svgDoc.getDocumentElement(); //svgDoc is the 'user svg'
System.out.println(svgDoc.getNamespaceURI()); //this returns 'null'
and it returned "null". My question is: the 'user' svg document is correctly loaded and displayed by Squiggle... It seems to be a "real" svg: It looks like this:
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" > <svg height="387" width="475" xmlns:xlink="http://www.w3.org/1999/xlink">> <g id="xray"> <image height="387" width="475" x="0" xlink:href="xray.jpg" y="0"/> </g> <g id="CommentNode_Tom"> <rect ............./> <text ......./> </g> <g id="CommentNode_Tom"> <rect ............./> <text ......./> </g> </svg>
Sorry, I'm not exactly an XML guru...am I missing anything? Thank you in advance.
Maria Teresa
At 06:15 AM 12/9/2003 -0500, you wrote:
Hi Maria,
maria teresa wrote:
[...]I am having a problem using Batik and I hope you can help me solve it. I have two svg files stored in a certain directory in my hard disk; one of them is a background image, while the other contains all the drawings that two different users dynamically add to the background.In order to extract the drawings of a single user, I parse the drawings file and extract only the nodes of interest by means of a node iterator and
a custom filter. Each node extracted is appended to the DOM tree of
the background.
This actually works!
I mean, the svg doc I obtain is exactly how I expected, but it is not rendered correctly: the canvas displays only the background.
I would suspect that the nodes you are getting from the 'overlay' drawing are not in the SVG namespace. It is also possible that the coordinate systems do not line up.
You can find out what namespace the elements from the 'user' document are in with 'getNamespaceURI()'.
Also a few other points,
1) Calling setDocument twice in close succession has only worked relyably very recently. 2) calling setDocumentState should be done before setting the document to have effect. 3) Modifications of the 'currently displayed' document should only be done in the updateManager's runnable queue.
So you might try just commenting out the first 'setDocument' call, this way you can avoid all the above issues.
Any suggestion is really appreciated! Thank you, maria teresa. PS: Here is an excerpt from my code: //f is the background svg file //svgCan the JSVGCanvas
Document svgDoc = parser.parse(f.toURL().toString()); svgCan.setDocument(svgDoc); // cosi'becco Xray "pulito"
svgCan.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);
//creating the node iterator: DocumentTraversal trav = (DocumentTraversal)doc; NodeIterator ni = trav.createNodeIterator( doc, NodeFilter.SHOW_ELEMENT, new FilterId(),//my custom filter true);
Element docRoot = svgDoc.getDocumentElement(); //iterate over the elements Node node; while((node = ni.nextNode()) != null){ //adding all the filtered nodes to the background System.out.println(node.getNodeValue()); Node importedNode = svgDoc.importNode(node, true); docRoot.appendChild(importedNode); } svgCan.setDocument(svgDoc); //why this does not work?
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]