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 Mon, 20 Apr 2009 19:39:34 GMT
> > I've found that Batik has problem with relative paths to external
images.
	
> Since you are building the document dynamically I'm not sure 
> what 'the same directory' means. 

:-) You are right, of course.
	
> Setting the base URI via DOM will have almost no impact on 
> performance, I strongly suggest you use that

Are SVGOMDocument.setURLObject and Document.setDocumentURI equivalent? I use
later one to avoid type cast between SVGOMDocument and Document in several
places of the following code:

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

if (svgStream != null) {
   DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
   Document svgDocument = builder.parse(new
ByteArrayInputStream(svgStream.toByteArray()));
   svgDocument.setDocumentURI(new
File(getServletContext().getRealPath("")).toURI().toString());
...

I am asking as I am getting error during transcoding of following lines:
TranscoderInput input = new TranscoderInput(svgDocument);
t.transcode(input, output);

java.lang.ClassCastException: org.apache.batik.dom.GenericElement cannot be
cast to org.w3c.dom.svg.SVGSVGElement at
org.apache.batik.dom.svg.SVGOMDocument.getRootElement(SVGOMDocument.java:233
) at
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTrans
coder.java:193) at

But maybe it is caused by svg:svg root element (below is part of
intermediate output)
<?xml version="1.0" encoding="utf-8"?>
<svg:svg xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:svg="http://www.w3.org/2000/svg"
         version="1.1"
         width="148.5mm"
         height="105mm"
         viewBox="0 0 148.5 105">
...
</svg:svg>	

Can be this error fixed somehow?

> > 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 '>'.
	
> The reference to HTML makes me think that the http server isn't sending
what 
> you want, but probably some sort of error document (404, etc). 

I only call Batik transcoder. The same result I am getting with Squiggle. I
don't know what they are trying to retrive from there. In svg file there is
link to JPEG file, but this file is at this URL
(http://localhost:8080/myApp/ + 'sunset.jpeg'). The second link is internal
link to #grey-filter.
I only found now that if there is placed svg file beside jpeg, Tomcat give
404 error if I try to display it in a browser. Strange. But maybe some kind
of security.

If there is used valid URI with file protocol:
xml:base="file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206
.0/webapps/myApp/"
I get error "Content is not allowed in prolog." (the same result also with 3
or 4 slashes).
If xml:base="file://C:/Progra..." (double slashes) are used, processing
takes much longer, but in result I get error "C".

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