[xsl] Running transformations using JSTL

Subject: [xsl] Running transformations using JSTL
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 25 Jul 2007 11:41:20 +0100
Does anyone have experience of running transformations using the JSP
Standard Tag Library?

I have a user who is attempting it, and is seeing symptoms that suggest that
the same Transformer is being used in more than one thread. This is
consistent with the JSTL spec, which says in section 13.1: 

"A more efficient approach is to process the transformation stylesheet once,
and then save this "transformer" object for successive transformations. The
specification allows implementations to support
transparent caching of transformer objects to improve performance."

But the JAXP Transformer is not reusable in this way. The Javadoc for
javax.xml.transform.Transformer says "An object of this class may not be
used in multiple threads running concurrently. Different Transformers may be
used concurrently by different threads." 

The object that should be cached is the Templates object, not the
Transformer.

Is it possible that jstl has got this wrong? It would seem a surprisingly
grave blunder. Perhaps in the Xalan implementation the Transformer object
can be safely reused across threads, despite the JAXP specification saying
it can't?

Any insights welcome.

Michael Kay
http://www.saxonica.com/

Current Thread