[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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
|
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
|