Subject: SUMMARY: Selecting unique value of an attribute From: Paul Terray <terray@xxxxxxxxxxxx> Date: Wed, 23 Aug 2000 19:24:52 +0100 |
I want to get a list with : -stuff -thing -this
<xsl:template match="text"> <xsl:apply-templates select="index"> <xsl:sort select="@entry"/> </xsl:apply-templates> </xsl:template>
<xsl:template match="index"> <xsl:if test="not(@entry = preceding::index/@entry)"> <xsl:value-of select="@entry"/> </xsl:if> </xsl:template>
Something like this: Define a key for every @entry of index: <xsl:key name="paul" match="index" use="@entry" />
Then walk through your index elements and choose only the first of
each group (i.e. each key)
<xsl:for-each select="index[generate-id()=generate-id(key('paul',@entry)[1])]">
now you have unique entries which need to be sorted: <xsl:sort select="@entry" />
Ok - here you are! Output, and that's all: <xsl:value-of select="@entry" />
The complete template is <xsl:template match="paul"> <xsl:for-each select="index[generate-id()=generate-id(key('paul',@entry)[1])]"> <xsl:sort select="@entry" /> <xsl:value-of select="@entry" /> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Interesting : Selecting unique , Miloslav Nic | Thread | Preventing indents/new lines in XSL, Deirdre O'Brien |
Re: dynamic pages with URL paramete, Aaron Miller | Date | Re: Xalan generates empty file for , Paul_Dick |
Month |