To capitalized this mailing list thread :http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702602@mail.gmail.com%3e

connect(rmiRegistryLocation);
canvas = new JSVGCanvas();
canvas.setDocument(createDoc());

with

  • private Document createDoc() throws ParserConfigurationException,
                            RemoteException, SAXException, IOException {
    
            String xmlDocument = remoteEngine.getSvgDocument();
            ByteArrayInputStream bais = new ByteArrayInputStream(xmlDocument.getBytes());
            String parser = XMLResourceDescriptor.getXMLParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
    
            return f.createDocument(DOC_URI, bais);
    }
    

Note the DOC_URI constant. It helps the user to set up the URI of the document. If the document works from itself, in a standalone mode and does not refers to other relative paths, it can be set at null.

Else, it is necessary to put an URI that points to a non existant file so that the relative URI can be resolved.

For example, an SVG document that refers to a widgets.svg file in a tag like this one:

{{{#!xml
<use x="-53.175" y="-194.283" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="widgets.svg#BarGauge" xlink:type="simple" xlink:actuate="onLoad" id="bar2" height="388.566" xlink:show="embed"/>
}}}

should be set up with an URI that points on a file of the same directory as the widgets.svg file.

It is possible to use some jar file URL to point inside a jar (so you can embed symbols svg inside your jar):
jar:file:///E:/ATOLE/gate/animator/MoowClient.jar!/panel.svg

  • No labels