Subject: Re: [xsl] FIRST-OCCURENCE From: Corey_Haines@xxxxxxxxxxxxxxx Date: Tue, 5 Mar 2002 11:18:49 -0500 |
You could do something like <xsl:apply-templates select="colors/colorids/color[@type = 'rude']" /> Then, have a template <xsl:template match="color"> <xsl:if test='position() = 1'>******</xsl:if><xsl:value-of select="text" /> </xsl:template> By selecting only those nodes you want in the <xsl:apply-templates />, you can use position() to recognize the first occurrence. -Corey "Kim Durand" <vsd18@xxxxxxxxxxxxxx> 03/05/2002 11:00 AM Please respond to xsl-list To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx cc: (bcc: Corey Haines) Subject: [xsl] FIRST-OCCURENCE hi i have a prob i have an xml file that looks like below <colors> <colorids> <color id = '1' type = 'pleasent'> <text> maroon </text> </color> </colorids> <colorids> <color id = '2' type = 'rude'> <text> red </text> </color> </colorids> <colorids> <color id = '3' type = 'pleasent'> <text> blue </text> </color> </colorids> <colorids> <color id = '4' type = 'happy'> <text> green </text> </color> </colorids> <colorids> <color id = '5' type = 'rude'> <text> orange </text> </color> </colorids> <colorids> <color id = '6' type = 'rude'> <text> bright yellow </text> </color> </colorids> </colors> i run a for-each for colors and want to attach ***** to the text of first occurence of the color with type = 'rude' and display the subsequent color text in a normal way example, i want the display of the above xml file to be like .. *****red orange yellow how do i do it.. I wanted to make use of the position() but position would only help me in getting the position of the nodes.. and i dont know which node has the required text. The only thing i know in the logic is , on the first occurence of a node, i need to append the ***** Can some one help me? XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FIRST-OCCURENCE, naha | Thread | [xsl] Lost Attributes?, Mike Ferrando |
[xsl] FIRST-OCCURENCE, Kim Durand | Date | Re: [xsl] Resetting context to main, Costantino Sertorio |
Month |