----- Original Message ----- From: "Tonny Kohar" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, May 12, 2005 8:06 PM
Subject: Re: relative URIs?
Hi,
On Thu, 2005-05-12 at 16:38 +0200, Lukasz Matuszczak wrote:How to use relative URLs while loading SVG documents into batik?
If you are using relative URI/URL make sure you set document base URL/URI if you are creating the doc on the fly. However, if you load the existing document, Batik will automatically set the doc base URL/URI.
I'm loading the existing document and it's not working.
If I put the document in the working directory for example and the use an URL "file:test.svg", it works. If the document is in a subfolder for example "doc" it doesn't work with URL "file:doc/test.svg". It turned out that the doc base is set to file:doc/, so it looks for urls in file:doc/doc/test.svg (if I put the copy of the document there, everything is OK).
The test document is very simple:
<?xml version="1.0" encoding="windows-1250" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="600" height="400" viewBox="0 0 600 400" xmlns="http://www.w3.org/2000/svg" version="1.1">
<desc>Example circle01 - circle filled with red and stroked with blue</desc>
<defs>
<linearGradient x1="100" gradientUnits="userSpaceOnUse" y1="200" x2="500"
y2="400" id="id0">
<stop offset="0" stop-color="#EBE0FF"/>
<stop offset="0.101961" stop-color="#33CC33"/>
<stop offset="0.490196" stop-color="#FFFF00"/>
<stop offset="0.878431" stop-color="#FF0000"/>
<stop offset="1" stop-color="#EBE0FF"/>
</linearGradient>
</defs>
<circle cx="200" cy="200" r="100" fill="url(#id0)" stroke="blue" stroke-width="10" />
</svg>
The message is: org.apache.batik.bridge.BridgeException: file:doc/test.svg:25 An I/O error occured while processing the URI: "file:doc/test.svg#id0" specified on the element <circle>
at org.apache.batik.bridge.BridgeContext.getReferencedElement(BridgeContext.java:638)
at org.apache.batik.bridge.PaintServer.convertURIPaint(PaintServer.java:348)
at org.apache.batik.bridge.PaintServer.convertPaint(PaintServer.java:259)
at org.apache.batik.bridge.PaintServer.convertFillPaint(PaintServer.java:228)
at org.apache.batik.bridge.PaintServer.convertFillAndStroke(PaintServer.java:146)
at org.apache.batik.bridge.SVGShapeElementBridge.createShapePainter(SVGShapeElementBridge.java:113)
at org.apache.batik.bridge.SVGCircleElementBridge.createShapePainter(SVGCircleElementBridge.java:124)
at org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(SVGShapeElementBridge.java:87)
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.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:95)
I set the URI with JSVGCanvas setURI method or with SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); doc = f.createDocument(uri, reader);
The result is the same. Regards, Lukasz Matuszczak
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
