[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Read the data only once.

Subject: Re: Read the data only once.
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 9 Apr 2002 08:20:58 +0100
xslt executing only once
Hi Raj,

> In my xsl I have a global varaible which caluculates and holds some
> data. I am using that variable from all over the xsl. I am making
> calls to named templates while creating the variable. Each time I
> call the varialbe, that named templates are being called to extract
> the value. I need a different behaviour here. In my case that
> variable remains constant through out the xsl. So I want to
> calculate the variable only once. Is there a easy way to implement
> this.

I assume that you mean you have something like:

<xsl:variable name="header">
  <xsl:call-template name="createHeader" />

<xsl:template name="createHeader">

Is that correct?

XSLT is, by definition, side-effect free, which means that the same
code can be executed multiple times and always give the same value.
The only thing that I can think of which would make the variable
change is if you are using some extensions within your named template
and those extensions have side-effects. Is that what you're doing?

The trouble is that because XSLT is designed to be side-effect free,
processors make optimisations when executing the stylesheet that
depend on this feature -- they might calculate the value of a variable
more than once to save the memory it would take to store the result,
or only call a function once with the same set of arguments because
they already know what the answer's going to be. Because the results
of evaluating something in XSLT cannot change, by definition, this
doesn't matter.

So basically, no, there isn't an easy way to tell your processor to
forget everything it knows about the fundamental rules of XSLT. What
you should do is redesign your stylesheet so that the information
that's being generated by the extensions is calculated prior to the
transformation and passed in to the stylesheet through parameters or
external files instead.



Jeni Tennison

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.