This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: untitled from Biray Giray: colour on first occurrence of an attribute value.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]