I generated the javadocs and found the SVG12DOMImplementation class.
I tried
Document cloned = DOMUtilities.deepCloneDocument(doc, SVG12DOMImplementation.getDOMImplementation());
and it worked. So I guess this is the proper way to clone a document.
Oscar
And sorry for the previous [SOLVED] post, I clicked the wrong button.
Oscar Picasso <[EMAIL PROTECTED]> wrote:
I tried
Document cloned = DOMUtilities.deepCloneDocument(doc, SVG12DOMImplementation.getDOMImplementation());
and it worked. So I guess this is the proper way to clone a document.
Oscar
And sorry for the previous [SOLVED] post, I clicked the wrong button.
Oscar Picasso <[EMAIL PROTECTED]> wrote:
Hi Cameron,
Thanks for your quick changes. I have test them it works with the code I gave in this thread.
However, in the actual code I need to use, the input DOM is cloned before the transcoding, so I tried something like that:
Document doc = factory.createDocument(myURL);
1- if I do
transcode(in, doc);
it works fine
2- if I do
Document cloned = (Docume nt) doc.cloneNode(true);
transcode(in, cloned);
I get the following the ClassCastException #1 below
3- if I do
Document cloned = DOMUtilities.deepCloneDocument(doc, SVGDOMImplementation.getDOMImplementation());
transcode(in, cloned);
I get the following the DOMException #2 below
How am I supposed to clone my document if want to be able to transcode it in such a case?
Thanks
Oscar
=== ClassCastException 1 ===
Exception in thread "main" java.lang.ClassCastException: org.apache.batik.bridge.BridgeContext
at org.apache.batik.bridge.svg12.SVG12TextElementBridge.addTextEventListeners(SVG12TextElementBridge.java:67)
at org.apache.batik.bridge.SVGTextElementBridge.initializeDynamicSupport(SVGTextElementBridge.java:340)
at org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(SVGTextElementBridge.java:251)
at org.apache.batik.bridge.svg12.SVGFlowRootElementBridge.buildGraphicsNode(SVGFlowRootElementBridge.java:317)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:210)
at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:161)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:77)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:206)
at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:89)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:157)
at org.jop.main.Main.main(Main.java:39)
=== DOMException #2 ===
Exception in thread "main" org.w3c.dom.DOMException: The current document is unable to create an element of the requested type (namespace: http://www.w3.org/2000/svg, name: flowRoot).
at org.apache.batik.dom.AbstractNode.createDOMException(AbstractNode.java:403)
at org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(SVGDOMImplementation.java:210)
at org.apache.batik.dom.svg.SVGOMDocument.createElementNS(SVGOMDocument.java:329)
at org.apache.batik.dom.AbstractDocument.importNode(AbstractDocument.java:342)
at org.apache.batik.dom.AbstractDocument.importNode(AbstractDocument.java:324)
at org.apache.batik.dom.util.DOMUtilities.deepCloneDocument(DOMUtilities.java:197)
at org.jop.main.Main.main(Main.java:33)
Cameron McCormack <[EMAIL PROTECTED]> wrote:Hi Oscar.
Oscar Picasso:
> So from what I see:
> 1- If I want to handle an onload event in my java code the target
> needs to have an " but="" valid="" _javascript_="">"
I consider this a bug in the SVGAbstractTranscoder. Setting the
KEY_EXECUTE_ONLOAD hint should force the document to be "dynamic" even
if the document contains no script.
> 2- If there is any flowRoot i n the SVG file and a onload attribute,
> I get a ClassCastException, even if the onload attribute is not on a
> flowXXX element.
Another bug, the SVGAbstractTranscoder class wasn't creating an SVG 1.2
specific BridgeContext.
Fix is in SVN.
Cameron
--
Cameron McCormack ICQ: 26955922
cam (at) mcc.id.au MSN: cam (at) mcc.id.au
http://mcc.id.au/ JBR: heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
What are the most popular cars? Find out at Yahoo! Autos
Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.
