xsl-list
[Top] [All Lists]

grouping by unique...

2003-06-17 13:49:55
I'd like to have an unique solution list.  Anyone can tell what's wrong with 
the following code which gives all solutions instead of the unique solutions?

The output needs to be: A B C D instead of A A B B C D. 

Thanks in advance for the help!

Here is the code.
<xsl:template match="report">
        <xsl:variable name="unique-solutions" 
              select="item[not(metadata/solution = 
preceding-sibling::metadata/solution)]/metadata/solution"    />
                                        
        <xsl:for-each select="$unique-solutions">
                <xsl:sort select="." />
                <xsl:value-of select="." />
        </xsl:for-each>                         
</xsl:template>


Here is the XML file.
<report>
        <item>
                <content>
                        ....
                </content>
                <metadata>
                        <solution>A</solution>
                        <solution>B</solution>
                        <solution>C</solution>
                </metadata>
        </item>
        <item>
                <content>
                        .....
                </content>
                <metadata>
                        <solution>A</solution>
                        <solution>B</solution>
                        <solution>D</solution>
                </metadata>
        </item>

</report



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>