You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "Boon, David" <da...@xelus.com> on 2001/07/09 22:18:18 UTC

Trancoder Exception, not an SVG Document

I'm trying to use the Transcoding api to convert an org.w3c.dom.Document
object to a JPEG image.  I'm using the sample code for the transcoder that
comes with batik.  

The Document object that I'm trying to transcode is the result of an XSL
transformation.  This document transforms when I use the rasterizer from the
command line.  When I try to transcode this document using the transcoder
api I get:
"org.apache.batik.transcoder.TranscoderException: The specified XML document
fragment is not an SVG document".  the method that looks to be throwing this
exception is transcode(TranscoderInput, TranscoderOuput)...

Here is the code that I'm using to perform the transformation:
            TransformerFactory tfactory = TransformerFactory.newInstance();
            File f = new File("d:/dev/svg/d3/d3.xsl");
            Transformer transformer = tfactory.newTransformer( new
StreamSource(f));
            OutputStream out = resp.getOutputStream();
            DOMResult result = new DOMResult();
            transformer.transform(new
StreamSource("file:///d:/dev/svg/d3/grid.xml"), result);
            Document resultNode = (Document)result.getNode();
            printDom( System.out, resultNode );
            transcode( resultNode);


Here is the code that I'm using to turn the dom into a jpeg:
        JPEGTranscoder t = new JPEGTranscoder();
        t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));
        TranscoderInput input = new TranscoderInput(doc);
        OutputStream ostream = new FileOutputStream("out.jpg");
        TranscoderOutput output = new TranscoderOutput(ostream);
        t.transcode(input, output);
        ostream.flush();
        ostream.close();

Environment information:
Windows NT
java version "1.3.1-rc1"
Xerces 1.2.3
Xalan 2.0
Batik-1.0



David Boon
Xelus, Inc.
Phone: (716)419-3344
http://www.xelus.com


Re: Trancoder Exception, not an SVG Document

Posted by Peter Becker <pb...@meganesia.int.gu.edu.au>.
Hello David,

I ended up writing the DOM to disk and letting the transcoder use the
file. You can find some of my ranting on this topic here:
  http://marc.theaimsgroup.com/?l=batik-users&m=99068584523412&w=2

and here:
  http://marc.theaimsgroup.com/?l=batik-users&m=99075782806755&w=2

Short version: Batik often claims to use a generic DOM interface but
expects (due to RTTI checks/casts) its own implementation, even in the
method that should be used to convert the DOM.

One approach I didn't try is to use some non-Batik conversion function.
And maybe it's not too hard to fix Batiks implementation, but I stumbled
from one problem into another so I gave up (the problem is not a big one
for me).

HTH,
  PeterB
  

> "Boon, David" wrote:
> 
> I'm trying to use the Transcoding api to convert an
> org.w3c.dom.Document object to a JPEG image.  I'm using the sample
> code for the transcoder that comes with batik.
> 
> The Document object that I'm trying to transcode is the result of an
> XSL transformation.  This document transforms when I use the
> rasterizer from the command line.  When I try to transcode this
> document using the transcoder api I get:
> 
> "org.apache.batik.transcoder.TranscoderException: The specified XML
> document fragment is not an SVG document".  the method that looks to
> be throwing this exception is transcode(TranscoderInput,
> TranscoderOuput)...

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