Title: Message
This example uses xml from a file, but if you define your Stream as a StreamSource you can use this to process the XML - XSL to create an in mem FO and feed it to the Driver as shown. hope this helps.  
   try
     {
   
            InputStream is =
                new BufferedInputStream(new FileInputStream(args[3]));
   
            StreamSource xmlSource = new StreamSource(is, args[3]);
   xmlSource.setSystemId("d:\\xmetal2\\Rules\\");
            is = new BufferedInputStream(new FileInputStream(args[2]));
            StreamSource xslSource = new StreamSource(is, args[2]);
   xslSource.setSystemId("d:\\xmetal2\\Rules\\");
            DOMResult result = new DOMResult();
 
            TransformerFactory f = TransformerFactory.newInstance();
            Templates templates = f.newTemplates(xslSource);
            Transformer transformer = templates.newTransformer();
   int nArgs = 0;
   for (int i = 0; i < args.length; i++) {
     int k = args[i].indexOf('=');
     if (k > 0)
   transformer.setParameter(args[i].substring(0, k),
      args[i].substring(k + 1));
     else
   args[nArgs++] = args[i];
   }
 
            transformer.transform(xmlSource, result);
 
            Driver driver = new Driver();
 
            driver.setRenderer(Driver.RENDER_PDF);
 
            driver.buildFOTree((Document) result.getNode());
 
            driver.format();
 
            driver.setOutputStream(new FileOutputStream(args[1]+".pdf"));
 
            driver.render();
  }
  catch (Exception ex) { System.out.println(ex.toString()); }
  System.out.println("Finished");
 }
 
 

John H. Wyman
5160 Darry Lane
Dublin, OH 43016
(614)-889-0698
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Wyman Genealogy Site <http://www.wyman.org>
Francis Wyman Assoc email List http://groups.yahoo.com/group/FrancisWymanAssoc
Wyman Family Genealogy Forum <http://genforum.genealogy.com/wyman/>
The Wyman Surname Message Board <http://www.familyhistory.com/messages/messages.asp?category=surname&forum=Wyman>

 

-----Original Message-----
From: Jim Urban [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 06, 2001 11:09 AM
To: [EMAIL PROTECTED]
Subject: Need Working Sample

Hi, I am new to FOP.  I have a servlet which dynamically generates XML.  I need to apply an XSL stylesheet containing FO tags to generate a FO version of the XML and then I need to run this FO version of the XML through FOP (or Driver) so the servlet can return a dynamically created PDF to the browser.  Does anyone have a working example of how to do this?  Only the XSL style sheet containing the FO tags used in the initial transform will be on disk.  Please help, I have to get this working.

Thanks,

Jim Urban
Product Manager
Netsteps Inc.
Suite 505E
1 Pierce Pl.
Itasca, IL  60143
Voice:  (630) 250-3045 x2164
Fax:  (630) 250-3046

Reply via email to