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 Brent L Johnson <br...@bjohnson.net> on 2001/07/30 09:32:20 UTC

not an SVG document

Well - I've managed to work through most of the previous problems I was
having.  I dropped the idea of doing the SVG transcoding output in JSP in
favor of a graphing servlet.

Here is my current problem:
org.apache.batik.transcoder.TranscoderException: The specified XML document
fragment is not an SVG document

I've managed to search through the mailing list archives and I did catch a
thread with someone having a similar problem.  But, they weren't running a
document through a parser first though.

I've found that I can open an SVG file and transcode it sending it the
InputStream of the file.  It reads it and works great!  (found a great SVG
program from www.jasc.com called WebDraw that outputs SVG)  I can take my
file straight out of WebDraw and transcode it to a jpeg.

The problem comes in when I parse the document with Xerces first, then send
the document to transcode instead of the file stream.  It keeps telling me
it's not an SVG document.  So, I had Xerces parse the document, then output
the XML file after the parse - and I saved this out to a test.svg file.  I
then passed the stream of that file into transcode and it worked fine!

Why can I output the parsed XML data from Xerces into a text file and
transcode that, but I can't transcode by sending the document directly?
Without being able to parse the file on the fly, I can't modify the
rectangle attributes to dynamically change my bar charts (unless I do
something crazy like parse the file, make the changes, save it out to a text
file, then open and transcode that).

Thanks,

- Brent


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


RE: not an SVG document

Posted by Brent L Johnson <br...@bjohnson.net>.
Alright - again - after a little more digging I did find this info in the
archives about DOMUtilities.deepCloneDocument:
http://marc.theaimsgroup.com/?l=batik-users&m=99486029612009&w=2

So, after trying the deepCloneDocument(), I get the same problem he did:
java.lang.ClassCastException: org.apache.batik.dom.GenericElement

Is there a fix for this problem yet?  Do Crimson and other parsers have the
same problem?  I could always switch to another one if I had to (since I'm
not currently needing schema support).  Here is the code I'm using set parse
and transcode:

DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;

org.w3c.dom.Document svgDoc =
org.apache.batik.dom.util.DOMUtilities.deepCloneDocument(document, impl);

JPEGTranscoder t = new JPEGTranscoder();
t.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
DEFAULT_PARSER_NAME);
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));

TranscoderInput input = new TranscoderInput(svgDoc);
OutputStream ostream = new FileOutputStream("out.jpg");
TranscoderOutput output = new TranscoderOutput(ostream);
t.transcode(input, output);

Sorry for spamming your mailboxes with all the problems :)

- Brent

> -----Original Message-----
> From: Brent L Johnson [mailto:brent@bjohnson.net]
> Sent: Monday, July 30, 2001 12:32 AM
> To: Batik-Users
> Subject: not an SVG document
>
>
> Well - I've managed to work through most of the previous problems I was
> having.  I dropped the idea of doing the SVG transcoding output in JSP in
> favor of a graphing servlet.
>
> Here is my current problem:
> org.apache.batik.transcoder.TranscoderException: The specified
> XML document
> fragment is not an SVG document
>
> I've managed to search through the mailing list archives and I did catch a
> thread with someone having a similar problem.  But, they weren't running a
> document through a parser first though.
>
> I've found that I can open an SVG file and transcode it sending it the
> InputStream of the file.  It reads it and works great!  (found a great SVG
> program from www.jasc.com called WebDraw that outputs SVG)  I can take my
> file straight out of WebDraw and transcode it to a jpeg.
>
> The problem comes in when I parse the document with Xerces first,
> then send
> the document to transcode instead of the file stream.  It keeps telling me
> it's not an SVG document.  So, I had Xerces parse the document,
> then output
> the XML file after the parse - and I saved this out to a test.svg file.  I
> then passed the stream of that file into transcode and it worked fine!
>
> Why can I output the parsed XML data from Xerces into a text file and
> transcode that, but I can't transcode by sending the document directly?
> Without being able to parse the file on the fly, I can't modify the
> rectangle attributes to dynamically change my bar charts (unless I do
> something crazy like parse the file, make the changes, save it
> out to a text
> file, then open and transcode that).
>
> Thanks,
>
> - Brent
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
>


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