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

RE: Variable confusion

Subject: RE: Variable confusion
From: Tompkins Tim <tim.tompkins@xxxxxxxxxxxxxxxxx>
Date: Fri, 17 May 2002 11:56:11 +0100
tompkins tim
	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
invocation?

	Regards
	Tim


> 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
> http://www.jenitennison.com/


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:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.