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

Re: XSL Grouping

Subject: Re: XSL Grouping
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 12 Nov 2001 17:56:22 +0000
jeni xsl grouping
Hi David,

> This is one transaction. First we group by Status, no prob. Now I
> want to group by CurrencyCode within each Status group. I'm just not
> seeming to get the right combo of xsl:key and key() XPath in the sub
> for-each. Can someone lend a hand? Tx :)

Sure. The key that you use for the second level group has to index
each Transaction by a combination of its Status and its CurrencyCode.
The easiest way to get such a combination value is using the concat()
function, so try:

<xsl:key name="TransactionsByStatusAndCurrencyCode"
         match="Transaction"
         use="concat(Status, '::', CurrencyCode)" />

[Obviously you don't have to use such a long name, I'm just doing so
to make things clear.]

At the point where currently you're retrieving all the Transaction
elements with a particular status, you need to filter that set to
include only those that have that Status *and* have a unique
CurrencyCode, with something like:

  key('TransactionsByStatus', $status)
    [generate-id() =
     generate-id(key('TransactionsByStatusAndCurrencyCode',
                     concat($status, '::', CurrencyCode))[1])]

And once you're processing such a Transaction, you can get all the
other Transaction elements with the same Status and CurrencyCode with:

  key('TransactionsByStatusAndCurrencyCode'
      concat(Status, '::', CurrencyCode))

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.