[xsl] xpath dynamic selection

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

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: 

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

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"/>
with the $step number of the item
and in alternative:
    <xsl:param name="start">
	<xsl:value-of select="ancestor::*/*/alt[@number=$anumber]"/>
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.


Wim Lemkens

Current Thread