C
Chris
I have a problem with grouping elements in my XSL. What I want to do
is select all of the distinct SCE_CGPC records, then by the FSG_SNAM
records for each SCE_CGPC and then again by MOA_NAME for each SCE_CGPC
and FSG_SNAM.
I have included a achunk of my XML to help expalin this:
This is a chunk of the XML file
<z:row SCE_CGPC='PGRE' FSG_SNAM='HOME' MOA_NAME='Full time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='OVERSEAS' MOA_NAME='Full time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='HOME MOA_NAME='Full time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='HOME' MOA_NAME='Part-Time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='OVERSEAS' MOA_NAME='Full time'
So for this chunk of data I would like to see the following:
PGRE - HOME - FULL TIME PART TIME
- OVERSEAS - FULL TIME
So effectively what I am trying to do is group by distinct (SCE_CGPC,
FSG_SNAM, MOA_NAME)
I have managed to get the distinct list of SCE_CGPC using the
following:
<xsl:key name="group-by-cgpc" match="/xml/rs:data/z:row"
use="@SCE_CGPC"/>
<xsl:template match="/">
<xsl:for-each select="/xml/rs:data/z:row[generate-id(.)=
generate-id(key('group-by-cgpc',@SCE_CGPC))]/@SCE_CGPC">
<xsl:value-of select="."/>
<xsl:call-template name="firstlevel">
<xsl:with-param name="coursegroupcode" select="." />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="firstlevel">
<xslaram name="coursegroupcode" />
<xsl:value-of select="concat('', @SCE_CGPC,' - There are
',count(key('group-by-cgpc', $coursegroupcode)),' records:')"/><br/>
</xsl:template>
</xsl:stylesheet>
But what this does not to do and where I am struggling is getting the
vales of FSG_SNAM for each of the SCE_CGPC's and the values of MOA_NAME
for each FSG_SNAM.
Any help would be greatly appreciated
Chris
is select all of the distinct SCE_CGPC records, then by the FSG_SNAM
records for each SCE_CGPC and then again by MOA_NAME for each SCE_CGPC
and FSG_SNAM.
I have included a achunk of my XML to help expalin this:
This is a chunk of the XML file
<z:row SCE_CGPC='PGRE' FSG_SNAM='HOME' MOA_NAME='Full time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='OVERSEAS' MOA_NAME='Full time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='HOME MOA_NAME='Full time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='HOME' MOA_NAME='Part-Time'
<z:row SCE_CGPC='PGRE' FSG_SNAM='OVERSEAS' MOA_NAME='Full time'
So for this chunk of data I would like to see the following:
PGRE - HOME - FULL TIME PART TIME
- OVERSEAS - FULL TIME
So effectively what I am trying to do is group by distinct (SCE_CGPC,
FSG_SNAM, MOA_NAME)
I have managed to get the distinct list of SCE_CGPC using the
following:
<xsl:key name="group-by-cgpc" match="/xml/rs:data/z:row"
use="@SCE_CGPC"/>
<xsl:template match="/">
<xsl:for-each select="/xml/rs:data/z:row[generate-id(.)=
generate-id(key('group-by-cgpc',@SCE_CGPC))]/@SCE_CGPC">
<xsl:value-of select="."/>
<xsl:call-template name="firstlevel">
<xsl:with-param name="coursegroupcode" select="." />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="firstlevel">
<xslaram name="coursegroupcode" />
<xsl:value-of select="concat('', @SCE_CGPC,' - There are
',count(key('group-by-cgpc', $coursegroupcode)),' records:')"/><br/>
</xsl:template>
</xsl:stylesheet>
But what this does not to do and where I am struggling is getting the
vales of FSG_SNAM for each of the SCE_CGPC's and the values of MOA_NAME
for each FSG_SNAM.
Any help would be greatly appreciated
Chris