| Subject: RE: How can I get the position of an element that has a descendan	t 'y' with value 'z' ? From: Kay Michael <Michael.Kay@xxxxxxx> Date: Fri, 4 Feb 2000 10:17:30 -0000 | 
>I would want to get the position of the element that has a descendant 'y'
whose value is 'z' and >put it in a variable, in the example the value of
the variable should be 2.
Try something like:
<xsl:variable name="pos">
   <xsl:for-each select="//element[descendant::y[.='z']][1]">
       <xsl:number/>
   <xsl:for-each>
</xsl:variable>
or (perhaps more efficient)
<xsl:variable name="pos">
   <xsl:for-each select="//element">
       <xsl:if test="*[descendant::y[.='z']]">
           <xsl:value-of select="position()"/>
       </xsl:if>
   <xsl:for-each>
</xsl:variable>
This won't work if there is more than one element that satisfies the
condition.
Mike Kay
<?xml version="1.0"?>
<elementList>
    <element>
        <x>
            <y>a</y>
        </x>
    </element>
    <element>
        <x>
            <y>z</y>
        </x>
    </element>
</elementList>
thank you
                
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: How to build a frames using XSL, Hunter, David | Thread | Re: How can I get the position of a, senthil | 
| RE: How to build a frames using XSL, Kay Michael | Date | RE: How to build a frames using XSL, Sebastian Rahtz | 
| Month |