RE: [xsl] Variable confusion

Subject: RE: [xsl] Variable confusion
From: Tompkins Tim <tim.tompkins@xxxxxxxxxxxxxxxxx>
Date: Fri, 17 May 2002 11:56:11 +0100
	Thanks everyone for the assistance. Your comments helped me solve
the problem.

	I have a further question...

	The code is fairly complex (I didn't write it) but discovered
XMLFilter objects were being
	pooled and reused. It appears that this means global variables are
cached in some way.
	Removing the pooling fixes the problem. I'm now looking in to using
Templates to 
	implement a XSL cache.

	My question is, is there a problem with using global variables with
compiled sytlesheets?
	As I understand it at the moment the stylesheets are interpreted for
every transform, or
	does the processor (I'm using Xalan) compile them on first


> Hi Tim,
> > I have a stylesheet with a global variable, the value of which is
> > taken from the input source. It seems the first time I run a
> > transform the variable is set correctly but on subsequent transforms
> > it is not and it retains it's first value.
> [snip]
> > to prove it, later in the stylesheet I have...
> >
> > alert('pageNum='+<xsl:value-of select="$pageNum"/>+
> >          ' trans-page='+<xsl:value-of
> > select="storpres/est/general/trans-page"/>);
> >
> > This tells me pageNum=1 but trans-page=2.
> I'm not sure whether it matters, but $pageNum is defined as
> /storpres/est/general/trans-page -- an absolute path -- while your
> xsl:value-of is giving the results of a relative path. If this alert
> is being generated somewhere where the root node is the context, then
> it doesn't matter at all, but somehow I doubt that's the problem.
> You haven't told us the context in which you're using the stylesheet,
> i.e. the code that you're using to invoke it, but I guess that you're
> using MSXML from within a client-side script.
> My guess would be that you're compiling the stylesheet once, and then
> running it against two separate input files, and that somehow the
> compiled stylesheet gets the value of the $pageNum fixed on the first
> invocation, and isn't reset the second time. You could try using
> the reset() method on the XSLProcessor object that you're using (if
> you're using one) rather than just changing the value of the input
> property, or you could create a new XSLProcessor for the second
> transformation.
> If that doesn't help, post the code that you're using to invoke the
> XSLT processor and we'll have a look at it.
> Cheers,
> Jeni
> ---
> Jeni Tennison

Legal Disclaimer:-

Internet communications are not secure and therefore the 
Barclays Group does not accept legal responsibility for the 
contents of this message.  Although the Barclays Group 
operates anti-virus programmes, it does not accept 
responsibility for any damage whatsoever that is caused 
by viruses being passed.  Any views or opinions presented 
are solely those of the author and do not necessarily 
represent those of the Barclays Group.

Replies to this e-mail may be monitored by the Barclays 
Group for operational or business reasons.

 XSL-List info and archive:

Current Thread