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]
Other format: [Raw text]

Re: Variable confusion


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/


 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]