[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Counting uniquely selected values of elements
Hi all,
I have tried to make a subject title as descriptive as possible, but I don't know if I have succeded very well. Anyway, here is my problem: I have a source.xml that has the following structure: <root> <a><b><c>this</c></b></a> <a><b><c>that</c></b></a> <a><b><c>that</c></b></a> <a><b><c>not this</c></b></a> <a><b><c>not that</c></b></a> <a><b><c>this</c></b></a> <a><b><c>this</c></b></a> </root> I want to count the occurences of each text in the c element (this, that, not this, not that). I have tried something like: <xsl:template match="/"> <xsl:apply-templates select="root"/> </xsl:template> <xsl:template match="root"> <xsl:apply-templates select="a/b/c[not(preceeding::a/b/c)]"/> <!-- This is not right, but I don't have any clue what to put into the select statement --> </xsl:template> <xsl:template match="a/b/c"> <xsl:value-of select="."/> occurs <xsl:value-of select="count(preceeding::a/b/c=.)"/> times. <!-- Syntax is not right here either --> </xsl:template> It is especialy the nested a/b/c (instead of just c) that throws me off, but I have never tried counting either. Thanks in advance! Ragulf Pickaxe :) _________________________________________________________________ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|