xsl-list
[Top] [All Lists]

xpath dynamic selection

2004-07-10 15:36:29
Hello,

When I look at all the examples every selection like 
select="child::item[(_at_)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[(_at_)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[(_at_)number=$anumber]"/>
    </xsl:param>    
with $anumber the number of the alternative.

But it returns nothing. If I remove the "[(_at_)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


<Prev in Thread] Current Thread [Next in Thread>