This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: untitled from Biray Giray: colour on first occurrence of an attribute value.
- From: TSchutzerWeissmann at uk dot imshealth dot com
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 16 Apr 2002 09:51:06 +0100
- Subject: [xsl] RE: untitled from Biray Giray: colour on first occurrence of an attribute value.
- Reply-to: xsl-list at lists dot mulberrytech dot com
Biray wrote:
>I need to select the first occurance of values in attributes of elements
and show them in different >color.
Hello Biray,
This is pretty much conjecture but:
One approach would be to use recursion: every time you come across a new
attribute value, call the template you're in with the updated list of values
encountered as a parameter. The trouble here would be that it makes it
difficult to apply other templates while you're stuck in a recursion loop.
I wonder if you could use a key? How about
<xsl:key name="firsts"
match="//Content[not(./preceding::Content/@ContentText=./@ContentText)]"
use="@ContentText"/>
should give you a handle on all the Content nodes with ContentText
attributes without precedent. Then when you were matching the Content nodes
you would set the colour using
<xsl:choose>
<xsl:when test="(count(. | key('firsts',@ContentText)) = 1)">
- do whatever with red here
</xsl:when>
<xsl:otherwise>
- do whatever in black here
</xsl:otherwise>
</xsl:choose>
This works across ALL Content nodes.
hth
Tom Weissmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list