xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ozhan Hassan <oz...@io.mds.rmit.edu.au>
Subject Problem rendering SVG
Date Mon, 05 May 2003 07:23:50 GMT
Hi,

I am experiencing some a weird problem while trying to render some SVG.
I have a simple java program which reads in an XML file and an XSLT
stylesheet (containing some SVG) and render it out to PDF. What happens is
my terminal just frezzes, and I can't kill the process or do anything
else. The process only hangs when I run my application, i.e. if I run fop
from the command line passing it the XSLT with the SVG, it works fine.

Here is SVG from the XSLT style sheet:

    <xsl:template name="DisplaySvg">
        <fo:instream-foreign-object>
            <svg:svg xmlns:svg="http://www.w3.org/2000/svg" 
            width = "300" height="200" viewBox="0 0 300 200" 
            xml:space="preserve">
              <svg:g style="fill:white; stroke:#000000">
                 <svg:line x1="0" y1="200" x2="0" y2="0"/>
                 <svg:line x1="0" y1="200" x2="200" y2="200"/>
                 <svg:rect x="10" y="150" width="20" height="50" 
                    style="fill:blue; stroke:#000000"/>
                 <svg:rect x="40" y="170" width="20" height="30" 
                    style="fill:black; stroke:#000000"/>
                 <svg:rect x="70" y="100" width="20" height="100" 
                    style="fill:green; stroke:#000000"/>
                 <svg:rect x="100" y="20" width="20" height="180" 
                    style="fill:yellow; stroke:#000000"/>
                 <svg:rect x="130" y="150" width="20" height="50" 
                    style="fill:red; stroke:#000000"/>
              </svg:g>
            </svg:svg>
        </fo:instream-foreign-object>
	</xsl:template> 

-------

The my java application which does what I explained above is:

import java.io.*;

// FOP libraries
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.Version;
import org.apache.fop.messaging.MessageHandler;

import org.xml.sax.InputSource;
import org.apache.fop.apps.FOPException;

import org.apache.avalon.framework.logger.ConsoleLogger;  
import org.apache.avalon.framework.logger.Logger; 

import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.sax.*;


class RenderingEngineXsltSvg
{
    
    // number of PDFs to be generated
    static final int OUTPUT_SIZE = 1;
    static final String INPUT_XML = "statement.xml";
    static final String INPUT_XSLT = "toXslFoSVG.xslt";
    static final String INPUT_DIR = "../../tmp/input/";
    static final String OUTPUT_DIR = "../../tmp/output/";

    
    public static void main(String args[])
    {
        try
        {
            // only create the Transformer which reads the XSLT once
            Transformer transformer = TransformerFactory.newInstance()
                .newTransformer(new StreamSource(INPUT_DIR + INPUT_XSLT));
                
            for(int i = 1; i <= OUTPUT_SIZE; i++)
            {
                String fileName = INPUT_XML;
                int fileLength = fileName.length();
                
                fileName = fileName.substring(0, fileLength - 4);
                String outFileName = OUTPUT_DIR + fileName + i + ".pdf";
            
                    Driver driver = new Driver();
                    driver.setOutputStream(new
FileOutputStream(outFileName));
                    Logger logger = new
ConsoleLogger(ConsoleLogger.LEVEL_INFO);
                    MessageHandler.setScreenLogger(logger);
                    driver.setLogger(logger);
                    driver.setRenderer(Driver.RENDER_PDF);

                    transformer.transform(new 
                        StreamSource(INPUT_DIR + INPUT_XML),
                        new SAXResult(driver.getContentHandler()));

                System.out.println("***** GENERATED PDF: " + i + "
*****");
            }
        }
        catch (javax.xml.transform.TransformerConfigurationException ex)
        {
            System.err.println("Exception: " + ex.toString());
        }
        catch (javax.xml.transform.TransformerException ex)
        {
            System.err.println("Exception: " + ex.toString());
        }
        catch (IOException ex)
        {
            System.err.println("IO Exception: " + ex.toString());
        }

        // Everything is OK - exit
        System.exit(0);
    }
}

---

Any help would be appreciated.

Regards,
Ozhan

----------------------------
Ozhan Hassan
Multimedia Database Systems
RMIT University
Email: ozhan@mds.rmit.edu.au
Phone: 9925 4118


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


Mime
View raw message