]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Back to transform example, reverted yesterday's change that removed BufferedOutputStream.
authorGlen Mazza <gmazza@apache.org>
Fri, 16 Jul 2004 03:36:14 +0000 (03:36 +0000)
committerGlen Mazza <gmazza@apache.org>
Fri, 16 Jul 2004 03:36:14 +0000 (03:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197793 13f79535-47bb-0310-9956-ffa450edef68

examples/embedding/java/embedding/ExampleFO2PDF.java

index d86e13b27ee6047b67d631d2143c8e0b65f2b224..bf44f07e18107916667b11c60d13726670a5ef8f 100644 (file)
 package embedding;
 
 // Java
+import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.IOException;
-import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.io.InputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 
 //JAXP
@@ -32,10 +31,7 @@ import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.Source;
 import javax.xml.transform.Result;
 import javax.xml.transform.stream.StreamSource;
-import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.sax.SAXResult;
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
 
 
 // FOP
@@ -63,35 +59,25 @@ public class ExampleFO2PDF {
             Driver driver = new Driver();
             driver.setRenderer(Driver.RENDER_PDF);
     
-            // Setup output stream
-            // For performance, also buffering output stream.
-            // Note: buffering recommended for FileOutputStreams
-            // but not for ByteArrayOutputStreams.
-            out = new java.io.FileOutputStream(pdf);
-            out = new java.io.BufferedOutputStream(out);
+            // Setup output stream.  Note: Using BufferedOutputStream
+            // for performance reasons (helpful with FileOutputStreams).
+            out = new FileOutputStream(pdf);
+            out = new BufferedOutputStream(out);
             driver.setOutputStream(out);
 
-            InputSource src = new InputSource(new FileInputStream(fo));
-            SAXParserFactory factory = SAXParserFactory.newInstance();
-            factory.setNamespaceAware(true);
-            XMLReader parser = factory.newSAXParser().getXMLReader();
-            parser.setContentHandler(driver.getContentHandler());
-            parser.parse(src);
-
-/*
-            // Setup input stream
-            Source src = new StreamSource(fo);
-
             // Setup JAXP using identity transformer
             TransformerFactory factory = TransformerFactory.newInstance();
             Transformer transformer = factory.newTransformer(); // identity transformer
             
+            // Setup input stream
+            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);
-*/
+
         } catch (Exception e) {
             e.printStackTrace(System.err);
             System.exit(-1);