Subject: [xsl] How can I select only unique combinations of attribute value? From: "Robert Eaton" <reaton@xxxxxxxxxxxxxxx> Date: Fri, 17 Nov 2006 12:28:50 -0000 |
I am trying to create some output based on the combination of several different attribute values. But the same combination of value could occur multiple times within the input document and I only want the output to appear once for each unique combination of attribute values. I have tried the code below, at this stage it just outputs the values while I was trying to get it working. I thought using preceding would look at the preceding node within the set being used in the for each, and that has been sorted, but this didn't seem to be the case. I am going about this in completely the wrong way? How should I compare a node within an iteration of a for-each with the same value for the previous node? Or is there a different/more efficient way to filter the results down to only unique value? <xsl:template match="/"> <xsl:call-template name="getListStyleNames"/> </xsl:template> <xsl:template name="getListStyleNames"> <xsl:for-each select="descendant::listitem"> <xsl:sort select="concat(../@style,@bodystyle,@style)"/> <xsl:if test="not(concat(../@style,@bodystyle,@style) = concat(preceding::listitem/../@style,preceding::listitem/@bodystyle,prec eding::listitem/@style))"> <!-- To test just output them for the moment. --> <xsl:element name="style"> <xsl:value-of select="concat(../@style,@bodystyle,@style)"/> </xsl:element> <xsl:element name="previousStyle"> <xsl:value-of select="concat(preceding::listitem/../@style,preceding::listitem/@bodyst yle,preceding::listitem/@style)"/> </xsl:element> </xsl:if> </xsl:for-each> </xsl:template> Thanks, Rob
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Grouping and Insertion, Florent Georges | Thread | Re: [xsl] How can I select only uni, Andrew Welch |
SV: [xsl] Combine content of separa, Per Osnes | Date | Re: [xsl] How can I select only uni, Andrew Welch |
Month |