Because, IMO, it allows the user to use the same pattern for virtually everything: 1. Create a TransformerFactory 2. Create a Transformer and optionally use a stylesheet 3. Specify the Source (DOM, stream, file, SAX....) 4. Specify the Result (DOM, stream, file, SAX....) 5. Start the transformation.
I use the JAXP part for XML parsing almost never because I can do most with this pattern. During my work I realized that most people don't even know about this pattern. They save the FO as a file or as a DOM and then send it to FOP. Very inefficient. Using the "one API approach" we can teach our users a few handy things with which they can do whatever they need: - Serializing a DOM to a file - Transforming an XML file to HTML - Creating a PDF from a Java object - you name it. Of course, in some situation you will need to learn a few additional things like using the TransformerHandler for pipelining multiple XSL transformations. But most of the things can be done using the Transformer. On 15.07.2004 20:52:23 Simon Pepping wrote: > On Wed, Jul 14, 2004 at 10:42:29PM -0000, [EMAIL PROTECTED] wrote: > > gmazza 2004/07/14 15:42:29 > > > > Modified: examples/embedding/java/embedding ExampleFO2PDF.java > > Log: > > Updated FO->PDF example to use JAXP. > > + // Setup JAXP using identity transformer > > + TransformerFactory factory = TransformerFactory.newInstance(); > > + Transformer transformer = factory.newTransformer(); // identity > > transformer > > + > > + // Setup input for XSLT transformation > > + Source src = new StreamSource(fo); > > + // 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); > > This is as much JAXP: > > Driver.run: > render(FOFileHandler.createParser(), source); > > FOFileHandler.createParser: > SAXParserFactory factory = SAXParserFactory.newInstance(); > factory.setNamespaceAware(true); > return factory.newSAXParser().getXMLReader(); > > Why is having a transformer object in between better? Jeremias Maerki