On Sat, 18 Apr 2009 21:50:07 +0200 Jan Tošovský <[email protected]> wrote:
> Hello Everyone, > > I've found that Batik has problem with relative paths to external That seems odd. I've done this many times. > images. Even if they are placed in the same directory and referenced > by the following code, they are hidden to Batik: > > <svg:image xmlns:xlink="http://www.w3.org/1999/xlink" id="img" > link:href="sunset.jpg"/> I'm assuming that you meant 'xlink:href' and not 'link:href'. > In a recent discussion I've found two methods how to fix it - by > setting batik.dom.svg.SVGOMDocument.setURLObject(URL) if document is > accessed via DOM or using xml:base attribute directly in SVG file. > > I am trying to make a very basic servlet for exporting svg files to > JPEG format. My servlet is based on code at > http://xmlgraphics.apache.org/batik/using/transcoder.html. I think it > would have impact on performace to try to set base URI via DOM > (several extra lines of code) so I am trying to add xml:base > attribute directly into SVG files. This is quite nightmare as using > xml:base in the following form I am getting the exceptions below: > > 1) http://localhost:8080/myApp > > org.apache.batik.bridge.BridgeException: The declaration for the > entity "HTML.Version" must end with '>'. > at > org.apache.batik.bridge.BridgeContext.getReferencedNode(BridgeContext.java:7 > 80) > at > org.apache.batik.bridge.BridgeContext.getReferencedElement(BridgeContext.jav > a:796) > > 2) file:///C:/Program Files/Apache Software Foundation/Tomcat > 6.0/webapps/myApp > > org.apache.batik.bridge.BridgeException: Content is not allowed in > prolog. at > org.apache.batik.bridge.BridgeContext.getReferencedNode(BridgeContext.java:7 > 80) > at > org.apache.batik.bridge.BridgeContext.getReferencedElement(BridgeContext.jav > a:796) > > 3) C:\Program Files\Apache Software Foundation\Tomcat > 6.0\webapps\myApp > > org.apache.batik.bridge.BridgeException: Unable to make sense of URL > for connection > at > org.apache.batik.bridge.BridgeContext.getReferencedNode(BridgeContext.java:7 > 80) > at > org.apache.batik.bridge.BridgeContext.getReferencedElement(BridgeContext.jav > a:796) Showing the actual code would be useful here. Maybe my brain is in worse condition than usual. But, I'm not really sure what you've tried here. In my experience, if you've given Batik a URL as the document there's no need to set xml:base. The document already has a base URL and all references are relative to that URL. Normally the xml:base and such are needed if you create the SVG on the fly. > BTW, for my purpose the best solution would be addition of new > transcoding hint which would be set on the fly - no processing DOM or > placing xml:base attribute into SVG document. The path is known in > the transforming step so it can be easily used... But, the xml:base feature is standard and supported by other viewers. I can't see the use of a proprietary approach for something this common. Unless, I'm really missing the point. G. Wade -- If a cluttered desk is the sign of a cluttered mind, what is the significance of a clean desk? -- Laurence J. Peter --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
