Kevin Lindsey wrote:
From: "Thomas DeWeese"



I'm currently using a Tomcat servlet to transform an uploaded SVG
document.
Once the document is transformed, I generate a PNG preview with Batik
and then insert that image into the transformed document as a base64
encoding image; however, my preview image is always blank.




[snip]


  The problem almost certainly has to do with the base url of the
document.
If you transcode from a stream it doesn't have one (unless you provide one
to the input stream).  You can also provide an xml:base attribute to set the
base to resolve URL's against.

> ).createSVGDocument( > "http://localhost:8080/uploadTest/";, > new StringReader( some_string_here ) > );

Actually it looks like you are providing a base so scratch this...

Are you sure you aren't getting error messages of any sort?


AFAIK, I'm catching all exceptions and none of them are firing and the
transformed document is generated correctly, minus the blank preview.

Not all errors are communicated using exceptions. Non-fatal errors are sent to the Transcoders ErrorHandler. By default it writes these to System.err - in Tomcat this probably goes to some error log or something... You could provide your own ErrorHandler that always threw an exception.

What's confusing me is that if I build the SVGDocument from the uploaded
file (which is a string), I get a preview, but when I build from the results
of the XSLT transform (again a string), I don't.  I generate the SVGDocument
with the exact same call (except for the string parameter, of course):

        SVGDocument svgDocument = new SAXSVGDocumentFactory(
            XMLResourceDescriptor.getXMLParserClassName()

You could see what happens with a 'null' XSL transformation (still probably mucks with doc types etc). Can you provide sample 'transformed' content? Also you might try printing/dumping the output of 'toString' on a bunch of the DOM nodes in this SVGDocument - you should get things like: batik.dom.svg.SVGOMSVGElement, batik.dom.svg.SVGOMGElement, batik.dom.svg.SVGOMPathElement, ... if instead you get batik.dom.GenericElement then you definately have a namespace/config issue.


I'm not doubting your suggestion...I'm just trying to understand what I'm
doing wrong.


FWIW, I am serializing the transformed and then reparsing to create a

new


SVG document.  My understanding from the code in Squiggle is that I have
to do this.

Pretty much, what you really need is for Xalan to create the output document using our DOM implementation. You might find it faster to deep clone the DOM into our implementation rather than serialize and parse.

Do you by any chance know of an example showing this that I can look at? This is my first real foray into Java+XML and embarrassingly, I'm feeling a little lost at this point.

Actually the latest version of the transcoders (I think in 1.5 but it might have happened shortly there after) will do this for you. So you could look at 'batik.transcoder.SVGAbstractTranscoder.java:206' from viewCVS. You could try it but for now I would stick with the parsing route.


Thanks for the help, Kevin KevLinDev - http://www.kevlindev.com


--------------------------------------------------------------------- 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]



Reply via email to