xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremias Maerki <dev.jerem...@greenmail.ch>
Subject Re: xml string input to XSLTInputHandler?
Date Thu, 05 Dec 2002 17:12:27 GMT
This is an extract from the tutorial I'm currently writing. It's not
using XSLTInputHandler but JAXP (javax.xml.transform...) to do the XSL
transformation.  I've modified it slightly so you can use a String as

        File xslt;
        File pdf;
        String xml;

        //Construct driver
        Driver driver = new Driver();
        //Setup logger
        Logger logger = new org.apache.avalon.framework.logger.ConsoleLogger();

        //Setup Renderer (output format)        
        //Setup output
        OutputStream out = new java.io.FileOutputStream(pdf);
        try {

            //Setup XSLT
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer(new StreamSource(xslt));
            //Setup input for XSLT transformation
            Source src = new StreamSource(new java.io.StringReader(xml));
            //Resulting SAX events (the generated FO) must be piped through to FOP
            Result res = new SAXResult(driver.getContentHandler());

            //Start XSLT transformation and FOP processing
            transformer.transform(src, res);
        } finally {

On 05.12.2002 16:50:00 Ciot, Thierry wrote:
> How do I pass an XML string to XSLTInputHandler?  As far as I can tell this
> class only accepts a file.  
> Should I use another class?
> I am trying to embed fop into a program.  I have some XML in a String object
> and I wouldn't want to write it to a temporary file.
> Any suggestion and code example welcome.
> Thierry.
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or disclose
> it to anyone else. If you received it in error please notify us immediately
> and then destroy it. 

Jeremias Maerki

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

View raw message