Urs Reupke wrote:
I tried the harder way, but I can't figure out how to do it:
You wrote
The _slightly_ harder (but much better) way to fix this would
be to construct an instance of our SVG DOM
(batik.dom.svg.SVGDOMImplementation). This will result in a
batik.dom.svg.SVGOMDocument object being used,
which seems reasonable - but how to insert the data I read from
my hard drive into the SVGOMDocument? I tried ImportNode(node, boolean)
as well as replaceChild(node, node) (using the DocumentElements as nodes
to be replaced and node to replace, respectively), but they invariably,
this results
in exceptions like "Cannot import node".
It isn't clear what svgDoc is JDOM.document or w3c.dom.Document?
I think it's a w3c Document in which case you are missing the main
point of the 'harder' way which is to avoid creating an intermediate
W3C DOM. However it looks like JDOM doesn't use the DOMImplementation
class to create Documents so you would have to create a DOMAdapter for
our SVGDOM (which should be easy, in your case you just need to
provide the createDocument method which you have already now).
Since you were able to pass this into setDocument
you might look at the code there since it was copying your
document in our DOM implementation:
if ((doc != null) &&
!(doc.getImplementation() instanceof SVGDOMImplementation)) {
DOMImplementation impl;
impl = ExtensibleSVGDOMImplementation.getDOMImplementation();
Document d = DOMUtilities.deepCloneDocument(doc, impl);
doc = (SVGDocument)d;
}
Currently, my code looks like this:
public void loadDocument(Document svgDoc) throws Exception{
String svgNS=SVGDOMImplementation.SVG_NAMESPACE_URI;
DOMImplementation impl=SVGDOMImplementation.getDOMImplementation();
SVGOMDocument
useDoc=(SVGOMDocument)impl.createDocument(svgns,"svg",null);
useDoc.replaceChild(useDoc.getDocumentElement(),svgDoc.getDocumentElement());
useDoc.setURLObject(new URL("My/URL/MySVG.svg"));
canvas.setDocument(useDoc); //canvas is of type JSVGCanvas
}
I don't think that I have to reconstruct the entire document by hand, so
I have to be missing
something - is there a way to import the complete document-structure of
one document to
another?
Thanks again
-Urs
Urs Reupke wrote:
up to now I used LoadSVGDocument(URL) to load files to display, and
it was good - but when today, for various reasons, I tried to convert
the program to use SetDocument,
things failed miserably:
Using JDOM 1.0, I wrote a method to read the SVG-File as a JDOM
Document, afterwards convert it to a w3c.dom Document, and finally
pass this w3c.dom Document
to the setDocument(w3c.dom.Document)-Method of my JSVGCanvas.
I didn't expect trouble at this stage, but it came: Instead of
displaying everything, only
"direct content" is displayed, images embedded via the <symbol>-Tag
aren't shown.
Which is bad, because my images are of quite repetitive content and
rely on
<symbol>/<use>.
Can you point me to a solution for the problem?
Thank you
-Urs
---------------------------------------------------------------------
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]