[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How can I get the position of an element that has a desc
>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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|