Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-20 Thread Jeremias Maerki
Just nitpicking, but could we call it ExampleFO2PDF-SAXParser instead of
just SAX, because the transformer solution relies on SAX, too? I don't
have a problem with long names. :-)

On 16.07.2004 21:14:18 Simon Pepping wrote:
 Perhaps it is a good idea to illustrate the transformer solution in
 ExampleFO2PDF, and the outlying SAX parser solution in
 ExampleFO2PDF-SAX.



Jeremias Maerki



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-20 Thread Glen Mazza
I renamed it yesterday.

Glen

--- Jeremias Maerki [EMAIL PROTECTED] wrote:
 Just nitpicking, but could we call it
 ExampleFO2PDF-SAXParser instead of
 just SAX, because the transformer solution relies
 on SAX, too? I don't
 have a problem with long names. :-)
 
 On 16.07.2004 21:14:18 Simon Pepping wrote:
  Perhaps it is a good idea to illustrate the
 transformer solution in
  ExampleFO2PDF, and the outlying SAX parser
 solution in
  ExampleFO2PDF-SAX.
 
 
 
 Jeremias Maerki
 
 



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-20 Thread Jeremias Maerki
Great. Sorry for the noise.

On 20.07.2004 22:34:28 Glen Mazza wrote:
 I renamed it yesterday.
 
 Glen
 
 --- Jeremias Maerki [EMAIL PROTECTED] wrote:
  Just nitpicking, but could we call it
  ExampleFO2PDF-SAXParser instead of
  just SAX, because the transformer solution relies
  on SAX, too? I don't
  have a problem with long names. :-)
  
  On 16.07.2004 21:14:18 Simon Pepping wrote:
   Perhaps it is a good idea to illustrate the
  transformer solution in
   ExampleFO2PDF, and the outlying SAX parser
  solution in
   ExampleFO2PDF-SAX.



Jeremias Maerki



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-17 Thread Glen Mazza
Good idea...this way those who prefer the
SAXParserFactory method can see how FOP would work
this way.  (I tried to show both cases in one example,
but it just made a mess of things.)  If you could take
care of this for us, it would be appreciated--else
I'll (probably) get to it eventually.

Glen

--- Simon Pepping [EMAIL PROTECTED] wrote:
 Perhaps it is a good idea to illustrate the
 transformer solution in
 ExampleFO2PDF, and the outlying SAX parser solution
 in
 ExampleFO2PDF-SAX.
 
 Regards, Simon
 



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-16 Thread Simon Pepping
Glen,

I can see Jeremias' argument for a single pattern to deal with all
situations, but I am pleased to see the SAX solution illustrated by an
example in this simplest case of all.

Perhaps it is a good idea to illustrate the transformer solution in
ExampleFO2PDF, and the outlying SAX parser solution in
ExampleFO2PDF-SAX.

Regards, Simon

On Thu, Jul 15, 2004 at 08:59:21PM -0700, Glen Mazza wrote:
 Thanks, Simon--I didn't think of this way of solving
 the problem--I just modified Jeremias' previous DOM
 example. However, I placed the method below
 temporarily in the example and committed it before
 returning to the Transformer version.  This way, we
 have a working example should we ever need to document
 this style (perhaps on a web page, so users are at
 least aware of it) in the future.
 
 Glen
 

-- 
Simon Pepping
home page: http://www.leverkruid.nl



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-15 Thread Jeremias Maerki
Glen,

I'd like this change reverted. Here's the justification:

VM warm-up (3 runs)
VM warm-up finished.
unbuffered: 766ms
unbuffered: 781ms
unbuffered: 766ms
unbuffered: 750ms
unbuffered: 703ms
unbuffered: 719ms
Average (unbuffered): 747ms
buffered: 609ms
buffered: 594ms
buffered: 562ms
buffered: 594ms
buffered: 578ms
buffered: 594ms
Average (buffered): 588ms
Difference: 22%

Not nothing. The test is run on a 110KB FO file with some SVG graphics
in it under FOP HEAD.

Buffering the OutputStream should be a best practice if the user is not
writing the output to a ByteArrayOutputStream.

See also: http://xml.apache.org/fop/embedding.html#performance

Thanks!

On 15.07.2004 00:45:27 gmazza wrote:
 gmazza  2004/07/14 15:45:27
 
   Modified:examples/embedding/java/embedding ExampleFO2PDF.java
   Log:
   Removed BufferedOutputStream line as unneeded in this case (Unsure if helpful
   for performance.)
   
   Revision  ChangesPath
   1.10  +0 -1  xml-fop/examples/embedding/java/embedding/ExampleFO2PDF.java
   
   Index: ExampleFO2PDF.java
   ===
   RCS file: /home/cvs/xml-fop/examples/embedding/java/embedding/ExampleFO2PDF.java,v
   retrieving revision 1.9
   retrieving revision 1.10
   diff -u -r1.9 -r1.10
   --- ExampleFO2PDF.java  14 Jul 2004 22:42:29 -  1.9
   +++ ExampleFO2PDF.java  14 Jul 2004 22:45:27 -  1.10
   @@ -59,7 +59,6 @@

// Setup output
out = new java.io.FileOutputStream(pdf);
   -out = new java.io.BufferedOutputStream(out);
driver.setOutputStream(out);

// Setup JAXP using identity transformer


Jeremias Maerki



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-15 Thread Glen Mazza
(Resending apparently...)

Excellent--thanks--will do tonight.  I didn't know the
reason for this method, and was unsure if it was just
legacy code.  I'll also put a comment of how it speeds
things up.

Thanks,
Glen

--- Jeremias Maerki [EMAIL PROTECTED] wrote:
 Glen,
 
 I'd like this change reverted. Here's the
 justification:
 
 VM warm-up (3 runs)
 VM warm-up finished.
 unbuffered: 766ms
 unbuffered: 781ms
 unbuffered: 766ms
 unbuffered: 750ms
 unbuffered: 703ms
 unbuffered: 719ms
 Average (unbuffered): 747ms
 buffered: 609ms
 buffered: 594ms
 buffered: 562ms
 buffered: 594ms
 buffered: 578ms
 buffered: 594ms
 Average (buffered): 588ms
 Difference: 22%
 
 Not nothing. The test is run on a 110KB FO file with
 some SVG graphics
 in it under FOP HEAD.
 
 Buffering the OutputStream should be a best practice
 if the user is not
 writing the output to a ByteArrayOutputStream.
 
 See also:
 http://xml.apache.org/fop/embedding.html#performance
 
 Thanks!
 
 On 15.07.2004 00:45:27 gmazza wrote:
  gmazza  2004/07/14 15:45:27
  
Modified:examples/embedding/java/embedding
 ExampleFO2PDF.java
Log:
Removed BufferedOutputStream line as unneeded in
 this case (Unsure if helpful
for performance.)

Revision  ChangesPath
1.10  +0 -1 

xml-fop/examples/embedding/java/embedding/ExampleFO2PDF.java

Index: ExampleFO2PDF.java
   

===
RCS file:

/home/cvs/xml-fop/examples/embedding/java/embedding/ExampleFO2PDF.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ExampleFO2PDF.java14 Jul 2004 22:42:29
 - 1.9
+++ ExampleFO2PDF.java14 Jul 2004 22:45:27
 - 1.10
@@ -59,7 +59,6 @@
 
 // Setup output
 out = new
 java.io.FileOutputStream(pdf);
-out = new
 java.io.BufferedOutputStream(out);
 driver.setOutputStream(out);
 
 // Setup JAXP using identity
 transformer
 
 
 Jeremias Maerki
 
 



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-15 Thread Simon Pepping
On Wed, Jul 14, 2004 at 10:42:29PM -, [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?

Regards, Simon

-- 
Simon Pepping
home page: http://www.leverkruid.nl



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-15 Thread Jeremias Maerki
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 -, [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



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-15 Thread Glen Mazza
Thanks, Simon--I didn't think of this way of solving
the problem--I just modified Jeremias' previous DOM
example. However, I placed the method below
temporarily in the example and committed it before
returning to the Transformer version.  This way, we
have a working example should we ever need to document
this style (perhaps on a web page, so users are at
least aware of it) in the future.

Glen

--- Simon Pepping [EMAIL PROTECTED] wrote:
 
 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?
 
 Regards, Simon
 
 -- 
 Simon Pepping
 home page: http://www.leverkruid.nl
 
 



Re: cvs commit: xml-fop/examples/embedding/java/embedding ExampleFO2PDF.java

2004-07-15 Thread Glen Mazza
Sounds good.

--- Jeremias Maerki [EMAIL PROTECTED] wrote:
 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.
 

snip/

 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.
 

snip/