[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: FIRST-OCCURENCE

Subject: Re: FIRST-OCCURENCE
From: Corey_Haines@xxxxxxxxxxxxxxx
Date: Tue, 5 Mar 2002 11:18:49 -0500
rude text
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:         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
  • FIRST-OCCURENCE
    • Kim Durand - Tue, 5 Mar 2002 10:58:05 -0500 (EST)
      • naha - Tue, 5 Mar 2002 11:48:25 -0500 (EST)
      • <Possible follow-ups>
      • Corey_Haines - Tue, 5 Mar 2002 11:15:41 -0500 (EST) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.