You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Christopher Giblin <CG...@zurich.ibm.com> on 2002/03/08 09:42:59 UTC

Reuse of transformers

Hi

The JAXP spec suggests to me  that Transformers can be reused at will,
threading considerations aside.
Xalan trax examples even demonstrate this.

Yet the Xalan "Usage Patterns" page, under the title "Multithreading",
states:

"A Transformer ... is a lightweight object that tracks state information
during the transformation, and should only be used to perform a single
transformation.  If you want to perform multiple transformations
(sequentially or concurrently) with the same stylesheet instructions, do
the following: ...
   2. ..For each transformation, use the Templates object newTransformer()
method to create a Transformer, and use that Transformer's transform(Source
xmlSource, Result transformResult) method to perform the transformation."

Multithreading is not a consideration for me but performance is very much
so. I am tweeking and need to apply the same transformation possibly
hundreds of times. If I can reuse the same transformer, great. I am now
skeptical due to the above statements, however.

Is Xalan recommending a "Best Practice" by endorsing new Transform instance
for each transformation? Or did I misread the JAXP spec?

Thanks, chris