RE: [xsl] XSL with multiple-threaded architecture..??

Subject: RE: [xsl] XSL with multiple-threaded architecture..??
From: "Duffey, Kevin" <KDuffey@xxxxxxxxxxxx>
Date: Tue, 27 Feb 2001 09:19:37 -0800
As a note, I think I figured out a way to do this..

I use a Templates object during the init() method of my servlet. It appears
that it does at least parse the XSL page..as one of them had a problem and
it showed there was a problem before the page was ever used. I store the
Templates objects in the Hashmap, and it is working..although I have still
to test it out.

I am still willing to listen to ideas for the best possible performance
using XSL.

Thanks.


> -----Original Message-----
> From: Kevin Duffey [mailto:kevin.duffey@xxxxxxxx]
> Sent: Monday, February 26, 2001 11:34 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] XSL with multiple-threaded architecture..??
> 
> 
> Hi there,
> 
> I am hoping this can be answered. I want to have my simple 
> MVC framework
> "cache" XSL stylesheets for faster runtime transformation. I 
> am using this
> bit of code in my java application. This happens for EVERY 
> request coming
> in.
> 
> TransformerFactory tFactory = TransformerFactory.newInstance();
> Transformer transformer = tFactory.newTransformer(xslStream);
> transformer.transform(xmlStream, new
> StreamResult(response.getOutputStream()));
> 
> The problem I am facing is that every request I read in the 
> XSL from the
> file system. I want to pre-load XSL pages when the 
> application starts, then
> apply them to the XML input (via JSP output of xml) upon each 
> request. Since
> Servlets are threaded, I want to make sure the process I use 
> is thread-safe.
> I have devised a simple Hashmap caching scheme where by when 
> the application
> starts, it loads all XSL pages into the Hashmap. I know this 
> will use a
> little bit of memory, but the performance gains should 
> warrant the use of
> more memory (so long as system page swapping doesn't occur). 
> In general,
> unless there are several hundred XSL files loaded, I am 
> really not worried.
> I think each XSL page is between 1K and 20K, and we will 
> probably have only
> a few hundred at most, if that.
> 
> I was about to write some code that read in each file. I then 
> thought I
> could just do something like:
> 
> File f = new File(filename);
> StreamSource xslStream = new StreamSource(f);
> 
> Then I could store the xslStream. The problem I see is that I 
> don't think at
> this point the XSL page is read in to memory. So I guess my 
> question is (for
> those that do both Java programming and XSL), how would I 
> read in the XSL
> page into memory BEFORE calling upon the
> TransformerFactory.newTransformer(xslStream);?? Is it even possible to
> "pre-compile" XSL pages and store that in memory, so that the 
> process is
> merely taking an already pre-compiled XSL page and running it 
> through the
> XSLT engine (Saxon in this case) with the XML input?
> 
> The goals are to cache XSL pages (pre-compiled if possible for best
> performance) and make it thread-safe so that multiple 
> threads/requests can
> use the same XSL page.
> 
> Thank you.
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread