Re: XSL-FO Engine comparisons

2001-07-31 Thread Steven Lane

I've been spending a lot of time lately with Docbook and XSL-FO as part
of the ongoing development of my next book, Processing XML with Java. To
that end, I've been putting the various XSL-FO engines on the market
through their paces. I'm trying to find one that will actually let me
produce the complete, finished book from my Docbook source code and Norm
Walsh's XSLT-to-XSL-FO stylesheet. I thought I'd share my experiences
here.

It's not FO-based, but I've been experimenting with ReportMill, which was
originally for use with WebObjects but is not (more or less) accessible via
Java. It looks pretty promising but I don't think it's geared toward long
structured documents.

--
Steve Lane
Vice President
Chris Moyer Consulting, Inc.
833 West Chicago Ave Suite 203
(312) 433-2421
http://www.fmpro.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: Need Working Sample

2001-07-06 Thread Steven Lane

The FopServlet reads a .fo file.  This is of no use to me.  I will
dyamically generate XML contianing only data.  This XML will be in a
StringBuffer.  I first need to apply an XSL sytle sheet to this
StringBuffer, generating a new XML stream (IN MEMORY).  This new (IN MEMORY)
XML stream then needs to be ran through FOP to generate a PDF stream which
will be sent back to the browser.  The embed sample also shows how to
process .FO files.  This is not what I want  The ONLY file that can be
on disk is the XSL file which contains the FO tags to apply to the XML data.

Applying XSL to your XML in memory should be fairly easy. The
transformation APIs in JAXP handle this. then just edit the servlet code to
handle something other than a file stream. I got this to work without much
problem a while ago. My code is appended below -- I think it worked with
0.17, haven't checked it in a while. It differs only slightly from the
original. The fo data comes in an HTTP parameter called fo, though you
can change the name. It loads this all into the String called fo. Then when
it sets up the driver, instead of passing it a FileInputSource, it passes
it a StringInputSource derived from the fo String.

I dimly recollect that the Driver interface changed a lot in 0.18 so some
of these methods may now be hidden, i.e. not called directly in the
servlet, but if you manually configure your driver, changing the type of
input source you hand it should not be hard.

-- sgl

/*-- $Id: FopServlet.java,v 1.2 2001/03/03 07:06:03 kellyc Exp $ --

 
   The Apache Software License, Version 1.1
 

Copyright (C) 1999 The Apache Software Foundation. All rights reserved.

 Redistribution and use in source and binary forms, with or without modifica-
 tion, are permitted provided that the following conditions are met:

 1. Redistributions of  source code must  retain the above copyright  notice,
this list of conditions and the following disclaimer.

 2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

 3. The end-user documentation included with the redistribution, if any, must
include  the following  acknowledgment:  This product includes  software
developed  by the  Apache Software Foundation  (http://www.apache.org/).
Alternately, this  acknowledgment may  appear in the software itself,  if
and wherever such third-party acknowledgments normally appear.

 4. The names Fop and  Apache Software Foundation  must not be used to
endorse  or promote  products derived  from this  software without  prior
written permission. For written permission, please contact
[EMAIL PROTECTED]

 5. Products  derived from this software may not  be called Apache, nor may
Apache appear  in their name,  without prior written permission  of the
Apache Software Foundation.

 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
 APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
 DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
 OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
 ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
 (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 This software  consists of voluntary contributions made  by many individuals
 on  behalf of the Apache Software  Foundation and was  originally created by
 James Tauber [EMAIL PROTECTED]. For more  information on the Apache
 Software Foundation, please see http://www.apache.org/.

 */



// Java
import java.io.*;
import java.net.URL;
import java.util.Date;

import javax.servlet.*;
import javax.servlet.http.*;

// SAX
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;


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


/**
 * Example servlet to generate a PDF from a servlet.
 * Servlet param is:
 * ul
 *   lifo: the path to a formatting object file to render
 * /ul
 *
 * Example URL:
http://servername/servlet/FopServlet?fo=/home/fop/example/readme.fo
 *
 */

public class FopStream extends HttpServlet
{
public static final String FO_REQUEST_PARAM = fo;

/**