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
input.


        File xslt;
        File pdf;
        String xml;


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

        //Setup Renderer (output format)        
        driver.setRenderer(Driver.RENDER_PDF);
        
        //Setup output
        OutputStream out = new java.io.FileOutputStream(pdf);
        try {
            driver.setOutputStream(out);

            //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 {
            out.close();
        }


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to