O'Reilly has a new book out about java and XSLT. THey have a sample chapter
online that briefly covers your issue:
http://www.oreilly.com/catalog/javaxslt/chapter/ch05.html

best,
-Rob

> -----Original Message-----
> From: Tom Amiro [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 27, 2001 6:20 AM
> To: [EMAIL PROTECTED]
> Subject: example of using templates object in a servlet
>
>
> I've found the sample servlet XSLTServletWithParams.java to
> be very helpful. I modified the following block in an attempt
> to implement a template for performance gains, but have a
> feeling that I'm missing something.
>
>         if (xslSource != null) // Now do we have a stylesheet?
>         {
>           Templates templates = tFactory.newTemplates(xslSource);
>           transformer = templates.newTransformer();
>           setParameters(transformer, request); // Set stylesheet params.
>           // Perform the transformation.
>           transformer.transform(xmlSource, new StreamResult(out));
>         }
>
> Should I put a declaration such as the following outside the doPost?
>
>     private static Templates templates = null;
>
> And then have a test within the above block such as
>
>       if (templates == null){
>           Templates templates = tFactory.newTemplates(xslSource);
>       }
>
> Otherwise, I suspect every time a user hits the servlet it recreates
> the templates object, thus adversely affecting performance.
>
> FYI - My servlet implementation is applying the same XSL stylesheet to
> the same XML document over and over with different parameters
> to change the resulting html.
>
> Tom
>

Reply via email to