xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Tošovský <j.tosov...@tiscali.cz>
Subject xml:base
Date Sat, 18 Apr 2009 19:50:07 GMT
Hello Everyone,

I've found that Batik has problem with relative paths to external 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"/>

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)

I have no idea how to set it properly. Is there possibility to use system
path? It can be built using String path =
getServletContext().getRealPath(""); so it could be automated somehow. In
case of URL it must be hardcoded only I think. Additionally there is a risk
it will have to be edited after a change of the URL.

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

Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message