I want to generate an SVG file from a DOM 
so I have tried this method but it generte the folowing exception
java.lang.UnsupportedOperationException: Don't know how to handle 
"image/svg+xml" as an output format. Neither an FOEventHandler, nor a Renderer 
could be found for this output format.
    at 
org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:224)
    at org.apache.fop.fo.FOTreeBuilder.<init>(FOTreeBuilder.java:98)
    at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:147)
    at org.apache.fop.apps.Fop.<init>(Fop.java:82)
    at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:227)
    at antidote.apps.DOM2SVG.convertDOM2SVG(DOM2SVG.java:43)
    at antidote.apps.Antidote.processXmlFiles(Antidote.java:227)
    at antidote.apps.Antidote.run(Antidote.java:104)
    at antidote.apps.Antidote.main(Antidote.java:111)

and this is the method
 public void convertDOM2SVG(Document xslfoDoc, File svg) {
        try {
            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
            // configure foUserAgent as desired
    
            // Setup output
            OutputStream out = new java.io.FileOutputStream(svg);
            out = new java.io.BufferedOutputStream(out);
    
            try {
                // Construct fop with desired output format and output stream
                Fop fop = fopFactory.newFop(MimeConstants.MIME_SVG, 
foUserAgent, out);
                
                // Setup Identity Transformer
                TransformerFactory factory = TransformerFactory.newInstance();
                Transformer transformer = factory.newTransformer(); // identity 
transformer
                
                // Setup input for XSLT transformation
                Source src = new DOMSource(xslfoDoc);
                
                // Resulting SAX events (the generated FO) must be piped 
through to FOP
                Result res = new SAXResult(fop.getDefaultHandler());
                
                // Start XSLT transformation and FOP processing
                transformer.transform(src, res);
            } finally {
                out.close();
            }
            
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }

    }
i will be grateful if someone can help me
thanks




             
---------------------------------
 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 

Reply via email to