[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Variation on a Grouping Question

Subject: Re: Variation on a Grouping Question
From: Gary L Peskin <garyp@xxxxxxxxxxxx>
Date: Thu, 21 Sep 2000 23:21:13 -0700
questio about the job
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.