Getting distinct sibling values from a key
Hi,
what I am trying to do is to display unique records. I have written a key (level 1) using the Muenchian method which works OK. What I need to do next is to get the unique occurrances of the next level (y)from the group-by-x key (on the x node) that I have created.
So for the records which have x=14 I want the return to give 15 and 19 and not 15(twice) and 19 and to give a count of the unique occurances.
I have the following XML:
<z:row x 14 y 15 z 22/>
<z:row x 14 y 15 z 22/>
<z:row x 14 y 19 z 22/>
<z:row x 18 y 15 z 22/>
<z:row x 18 y 10 z 22/>
I have written the following XSL to try and group the records:
<xsl:output method="html"/>
<xsl:key name="group-by-x" match="/xml/rs:data/z:row" use="@x"/>
<xsl:template match="/">
<xsl:for-each select="z:row[generate-id(.)= generate-id(key('group-by-x',@x))]/@x">
<xsl:value-of select="."/>
<xsl:call-template name="firstlevel">
<xsl:with-param name="xcode" select="." />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="firstlevel">
<xsl:param name="xcode" />
<xsl:value-of select="concat('', @x,' - There are ',count(key('group-by-x', $xcode)),' records:')"/><br/>
</xsl:template>
</xsl:stylesheet>
This does what I want for the first level. The next stage is to display what each unique occuraances of 'y' there are in terms of x and then what occurances of z there in terms of x and y together. I have tried using the following:
select="key('group-by-x', .)/following-sibling::y"> but this doesnt work because of the way that my XML is structured.
Can anyone please advise as to how I could get round this problem?
Thanks in advance,
Chris
|