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 RE: xml:base
Date Sun, 19 Apr 2009 21:18:49 GMT
> > 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"
> > xlink:href="sunset.jpg"/>

> Showing the actual code would be useful here.
> Normally the xml:base and such are needed if you create the SVG on the
> fly.

Ahh, what stupid, I forgot to mention my file is created on the fly - via
XSLT transformation:

This transformation is done via javax.xml.transform using Saxon9 as
TransformerFactory. As I need convert its output into input of Batik, I use
ByteArrayOutputStream:

ByteArrayOutputStream svgStream = new ByteArrayOutputStream();
transformer.transform(new StreamSource(sourceFile), new
StreamResult(svgStream));

svgStream is then used in the following way:

TranscoderInput input = new TranscoderInput(new
ByteArrayInputStream(svgStream.toByteArray())); // maybe too complicated,
better solution is appreciated

TranscoderOutput output = new TranscoderOutput(out); // out is
ServletOutputStream
t.transcode(input, output);

If in this forum the attachments are supported, I can enclose the whole
file. But the main idea is mentioned above.

In the meantime I found a way how to fill xml:base with no hardcoding - I
can pass appropriate value as parameter into XSLT transformation and in XST
template only use something like <svg:svg xml:base="{$base}" ...>

So it doesn't matter if public (URL) or local (Path) xml:base value is to be
used, but any working example how it should be specified (its syntax) is
welcomed. All my attempts fails...

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