[xsl] xpath dynamic selection

Subject: [xsl] xpath dynamic selection
From: Wim Lemkens <wim.lemkens@xxxxxxxxxx>
Date: Sun, 11 Jul 2004 00:36:29 +0200
Hello,

When I look at all the examples every selection like 
select="child::item[@value>3]" has a constant value to test against ("3" in 
this case).
Can't this be done with a variable? eg: 
select="child::item[@value>$basevalue]"

Because I'm trying to create a structure like this...
usecase
->item(s) (kind of ordered list)
  ->alt (with @number parameter)
->alternativecourse
  ->alternative (with @number parameter)
    ->item(s)

the "alternative"s should get the itemnumber from the matching "alt"s.
It try to do this by calling the alts in item with:
  	<xsl:apply-templates match="alt">
	  <xsl:with-param name="step" select="$step"/>
	</xsl:apply-templates>
with the $step number of the item
and in alternative:
    <xsl:param name="start">
	<xsl:value-of select="ancestor::*/*/alt[@number=$anumber]"/>
    </xsl:param>    
with $anumber the number of the alternative.

But it returns nothing. If I remove the "[@number=$anumber]" part it always 
returns 1, so I guess it returns the first match.

I also don't understand how I can get the @step value from the alt. 
adding /attribute::step after the */*/alt doesn't seem to work.

If there are better ways to do this, please let me know, want I don't realy 
understand the reasoning after the xsl structure.


Thanks,

Wim Lemkens

Current Thread