|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Variation on a Grouping Question
Raj Muchhala wrote:
>
> Hi All,
>
> OK, I know I have a grouping problem and the FAQ has been very helpful up
> this point. But
> now I'm stuck...
Raj --
If you want to stick with the <xsl:key ...> element, the following seems
to work okay:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'
xmlns:test='urn:mytest'>
<xsl:param name="job" select="'46521'"/>
<xsl:key name="by_city" match="z:row" use="@city"/>
<xsl:template match="/">
<html>
<body><i>Job Number: <xsl:value-of select="$job"/></i>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<!-- ************************************************** -->
<xsl:template match="rs:data">
<xsl:apply-templates select="z:row[@job_number = $job
and generate-id(.) = generate-id(key('by_city', @city)[@job_number =
$job])]" >
<xsl:sort select="@city" />
</xsl:apply-templates>
</xsl:template>
<!-- ************************************************** -->
<xsl:template match ="z:row">
<tr>
<td><b><xsl:value-of select="@city"/></b></td>
</tr>
<xsl:for-each select="/xml/rs:data/z:row[@job_number=$job and
@city=current()/@city]">
<tr>
<td>Date:<xsl:value-of select="@date"/></td>
<td>Qty:<xsl:value-of select="@qty"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------------------
You could also eliminate the <xsl:key ...> altogether and change the
select in the apply-templates within your rs:data template to:
select="z:row[@job_number = $job and
not(@city = preceding-sibling::*[@job_number = $job]/ @city)]"
Gary
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








