Re: [xsl] finding postion from value of attribute

Subject: Re: [xsl] finding postion from value of attribute
From: Jarkko.Moilanen@xxxxxx
Date: Tue, 21 Oct 2003 15:19:21 +0300
Lainaus David Elsmore <delsmore@xxxxxxxxxxxxx>:

<!-- Hi,
<!-- 
<!-- I have the following xml input and would like to identify the position 
<!-- of the <answer/> element with the 'correct' attribute within the 
<!-- <question/> context and output it as as an integer ( in this case 3).
<!-- 
<!-- <question>
<!--     <answer/>
<!--     <answer/>
<!--     <answer eval="correct">
<!--     <answer/>
<!-- </question>
<!-- 
<!-- Any suggestions much appreciated

<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 
<xsl:template match="/question">
  <xsl:apply-templates select="answer"/>
</xsl:template>
 
<xsl:template match="answer[@eval='correct']">
   <xsl:value-of select="./@eval"/> answer is number:
  <xsl:value-of select="position()"/>
</xsl:template>
 
</xsl:stylesheet>


***************************************************
* Jarkko Moilanen                                 *
* Project Manager, ITCM (www.itcm.org)            *
* Profound XML technology Expert                  *
* University of Tampere                           *
* Hypermedia Laboratory                           *
***************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread