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

Re: 2 level Grouping through attributes

Subject: Re: 2 level Grouping through attributes
From: ronald heller <ronald@xxxxxxxxxxx>
Date: Mon, 11 Feb 2002 13:49:43 +0100
next level ron heller
Try the following:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
   <xsl:key name="level1" match="XML_OUTPUT/@UserID" use="." />

<xsl:key name="level2" match="XML_OUTPUT/@CategoryID" use="." />

<xsl:template match="/">
<xsl:for-each select="//XML_OUTPUT[generate-id(@UserID) = generate-id(key('level1', @UserID)[1])]">
<xsl:variable name="user">
<xsl:value-of select="@UserID" />

               <xsl:value-of select="generate-id(@UserID)" />

<USER ID="{$user}">
<xsl:for-each select="//XML_OUTPUT[generate-id(@CategoryID) = generate-id(key('level2', @CategoryID)[1]) and @UserID=$user]">
<xsl:variable name="category">
<xsl:value-of select="@CategoryID" />

<CATEGORY ID="{$category}" TITLE="{@CategoryTitle}">
<xsl:for-each select="//XML_OUTPUT[@CategoryID=$category and @UserID=$user]">
<CONTENT_ITEM ID="{@ContentItemID}" TITLE="{@ItemTitle}">

Cheers RH

At 09:35 AM 2/11/02 +0200, you wrote:

I am trying to achieve multi level grouping (actually two levels) of the
next XML.

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.