This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: XSL with multiple-threaded architecture..??


Take a look at the SampleServlet.java code issued as a sample with the Saxon
download. It's written to use the TrAX API.

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of
> Kevin Duffey
> Sent: 27 February 2001 07:34
> To: xsl-list@lists.mulberrytech.com
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]