Help. Using a variable to get the position of a node.

Donal

Usenet Archive
Joined
Mar 5, 2002
Messages
4
Reaction score
0
I have the following:

<xsl:variable name="position"><xsl:value-of
select="position"/></xsl:variable>
<xsl:attribute name='style'><xsl:value-of
select="//ExportData/Definition/Column[$position]/Style"/></xsl:attribute>

However, //ExportData/Definition/Column[$position]/Style always seem to return //ExportData/Definition/Column[1]/Style.

Any ideas?
 

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
"Donal" wrote:

I have the following:

<xsl:variable name="position"><xsl:value-of
select="position"/></xsl:variable>
<xsl:attribute name='style'><xsl:value-of
select="//ExportData/Definition/Column[$position]/Style"/></xsl:attribute>

However, //ExportData/Definition/Column[$position]/Style always seem to return //ExportData/Definition/Column[1]/Style.

Any ideas?

Use:

<xsl:variable name="position" select="position"/>

Outputting a value (as you did) in the body of an xsl:variable makes it contain an RTF (Result Tree Fragment), which has a root with a single text node child. A tree used in a predicate is evaluated as a boolean and always returns true. This means that:

//ExportData/Definition/Column[$position]/Style

selects all "Style" children of all //ExportData/Definition/Column elements (because the predicate is true and does not eliminate any node.

Then, given a nodeset, xsl:value-of outputs the first node in document order. This is how you got the first "Style" child of:

//ExportData/Definition/Column[1]

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 

Donal Conlon

Usenet Archive
Joined
Aug 12, 2003
Messages
1
Reaction score
0
Excellent explanation, thank you.

*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top