Matthew Good wrote:

I've written a Java Servlet to rasterize SVG files and I can run it
under Tomcat 4. However problems arise when I try to rasterize files
which use the <use> tag to reference a resource in another file. For
example, the sample files that come with Batik use this tag to insert
the logo from batikLogo.svg. I believe this may be due to security
restrictions on classes running in the servlet context to restrict their
access to files, but I'm not sure about this.

In order to get the InputStream I pass to the Transcoder I use
getServletContext().getResourceAsStream(filename) which enables me to
access a file within the servlet context.  Does anyone else have any
suggestions on what may be the cause of this problem or how to fix it?

In order to resolve relative URLs Batik _must_ know the base URL for the document. By simply passing in the Stream Batik has know way to know where the file came from and hence no idea where to find resources linked via relative URLs.

  There are three common solutions to this problem:
1) I believe you can provide the 'source' url when you construct the
   InputSource for the transcoder.
2) Batik supports xml:base to control the base url used for relative
   url references.
3) Only use absolute URLs.

The stack trace of the exception I'm getting is:

An I/O error occured while processing the URI
'batikLogo.svg#Batik_Squiggle' specified on the element <use>
        at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
        at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source)
        at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
        at 
edu.virginia.mag5v.SVGWebtools.SVGRasterizerServlet.doPost(SVGRasterizerServlet.java:104)

-Matt


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