You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by jason heddings <Ja...@Sun.COM> on 2001/05/10 18:06:04 UTC

"Templates" Usage

Hello Folks!

  Some of you have asked for an example where I used a "Templates"
object instead of the factory to get Transformer(s).

  In the attached file, I have a "TransformerCache" (which is a little
incorrect, but I didn't want to re-use "TransformerFactory").  The cache
object is responsible for returning Transformer objects.  I am using
this from a servlet, so I wanted to ensure that I always have a new
transformer object for each request (since requests happen in concurrent
threads).  The XSL file may change, so I hash based on that value and
save a new Templates object for a given XSL document.  Creating this
Templates object parses the XSL document so when newTransformer( ) is
called, it doesn't have to parse it again (this is the slowest part of
creating the Transformer in the TransformerFactory.newTransformer(
xslSource ) method).

  So, anyway...  There it is.  Feel free to ask questions, and by all
means, if you have a better way of doing something like this or another
example, I'd love to see it (and I'm sure others would, too!).

'Till later,
--jah
 

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      \\\|///                 Jason Heddings             ((
     \\ ~ ~ //                303.272.5166 (x75166)    C|~~|
     (/ @ @ /)                Jason.Heddings@Sun.COM    `__'
 ~~oOOo~(_)~oOOo~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~