You can use org.apache.fop.apps.Driver to get the org.xml.sax.helpers.DefaultHandler and fire sax events on that. The initialization code is highly order dependent.
// THIS IS JUST SOME SET UP CODE // set up Logger Hierarchy hierarchy = Hierarchy.getDefaultHierarchy(); PatternFormatter formatter = new PatternFormatter( " [%{priority}]:%{message}\n%{throwable}" ); LogTarget target = new StreamTarget(System.out, formatter); hierarchy.setDefaultLogTarget(target); Logger log = hierarchy.getLoggerFor("fop"); // get output stream one way or FileOutputStream out = new FileOutputStream( "filename.pdf" ); // HERE's THE CODE YOU NEED Driver driver = new Driver(); driver.setOutputStream(out); driver.setLogger( log ); driver.setRenderer( driver.RENDER_PDF ); DefaultHandler handler = (DefaultHandler) driver.getContentHandler() ); handler.startDocument(); ... handler.endDocument(); out.close(); After seeing Yuri's implementation I'd go with his. The above avoids having to create a XML data file but you wind up with quite a bit of wrapper code and loose the XSL template cache. However it is another direct way, it also gives you a little more control since you are fireing SAX events from Java rather than XSLT. Then again that kind of stuff should probably be done in an extension. JohnPT fop-dev-return-11456-jthaemlitz=oreillyauto.com@XML. APACHE.ORG To: [EMAIL PROTECTED] cc: 11/12/01 01:39 PM Subject: RE: Question on XSLTInputHandler Please respond to fop-dev Before I go on, let me say I turned my XSLT-transformed document into a string and then handed it to Fop. XML tree -> Xalan transform handler -> serialize -> string -> Fop However, this is silly. It would be more intelligent to be able to send Sax events to Fop. I found a class in the Fop source that handles it, but it seems to care about Jim Clark's XML handlers. I use the Apache XML code and would rather stick with those. I plan on looking into the Fop content handler that claims need of Clark's stuff and see if it really cares, or finding another content handler, or creating a regular Sax content handler that can talk to Fop. Perhaps Cocoon has one since you can have PDF generated at the end of a Cocoon pipeline. Does anyone know of one that already exists? --- Jim Wright <[EMAIL PROTECTED]> wrote: > Thanks a lot! > > jw > > -----Original Message----- > From: Clute, Andrew [mailto:[EMAIL PROTECTED]] > Sent: Monday, November 12, 2001 1:13 PM > To: '[EMAIL PROTECTED] ' > Subject: RE: Question on XSLTInputHandler > > > Sure... > Attached is a new FOInputHandler.java file. > As you can see all I did was add a new method to set a String > input-source, > and to get an InputSource that was fed from a StringReader. > > Let me know if you have any questions. > > -----Original Message----- > From: Jim Wright > To: [EMAIL PROTECTED] > Sent: 11/12/2001 2:02 PM > Subject: RE: Question on XSLTInputHandler > Andrew: > > For me, at least, that example would be greatly appreciated. Could > you > send it along? > > Thanks... > > jw > > -----Original Message----- > From: Clute, Andrew [ mailto:[EMAIL PROTECTED]] > Sent: Monday, November 12, 2001 12:58 PM > To: '[EMAIL PROTECTED] ' > Subject: RE: Question on XSLTInputHandler > > There is no way to do it without modifying the source code. > I added an InputSource that took in a String...took about 10 minutes > and > 5 lines of code (I did it on .20.1). > I can send you the code to make the changes, if you want. > Any reasons why this is not part of the class structure? > -andrew > > -----Original Message----- > From: Ulrich Mayring > To: [EMAIL PROTECTED] > Sent: 11/12/2001 1:49 PM > Subject: Question on XSLTInputHandler > Hello, > I've looked at the example servlet and found that the > XSLTInputHandler > takes as input a java.io.File. However, I am constructing the XML > document dynamically and have it as a java.lang.String in memory. It > seems unnecessary I/O to write it out to a temporary file, just to > pass > it to the XSLTInputHandler. Looking at the source of > XSLTInputHandler.java I didn't find any alternate way to call it. > What > would the recommended procedure be in this case, where I already have > the XML document in memory? > thanks in advance for any pointers, > Ulrich > -- > Ulrich Mayring > DENIC eG, Systementwicklung > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, email: [EMAIL PROTECTED] > > __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]