Using MSXML 4.0, XSLT version 1.0. Producing HTML using classic ASP + XSL + an XML file.
Hello sirs, madams and gurus. I have an XML document like this:
Code:
<list>
<contact id="1">
<name>Steve</name>
<colors>|blue|green|yellow|</colors>
</contact>
<contact id="2">
<name>Bill</name>
<colors>|red|green|</colors>
</contact>
<contact id="3">
<name>Susan</name>
<colors>|white|green|lightgreen|</colors>
</contact>
</list>
I get one or more color names sent to the asp page, where I recieve and turn them into a XML fragment which I send to the XSL page as a parameter. The XML fragment looks like this if "blue, green" is sent to the asp page:
Code:
<palette>
<item>blue</item>
<item>green</item>
</palette>
What I'm trying to achieve is a list of the names which has one or more of the colors sent to the asp page. This is the XSL I´ve done so far (which doesn't produce exactly what I want):
Code:
<xsl:param name="paletteXML"/>
.
.
.
<xsl:apply-templates select="/list/contact"/>
.
.
.
<xsl:template match="contact">
<xsl:variable name="current_colors" select="colors"/>
<xsl:variable name="current_name" select="name"/>
<xsl:for-each select="msxsl:node-set($paletteXML)/palette/item">
<xsl:if test="contains($current_colors, concat('|',.,'|'))">
<xsl:value-of select="$current_name"/><BR />
</xsl:if>
</xsl:for-each>
</xsl:template>
This results in the following output...
Steve
Steve
Bill
Susan
...since Steve has both green and blue in his colors node. But I really want the following output:
Steve
Bill
Susan
That is - even if one person has more than one of the colors sent to the asp page, I only want that name to be listed once.
Been trying for two days, and looking at grouping etc, but I'm kind of stuck. Any help or pointer is very very much appreciated. Thanks.
/Mike