[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 2 level Grouping through attributes
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="/"> <ROOT> <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:variable> <xsl:comment> <xsl:value-of select="generate-id(@UserID)" /> </xsl:comment> <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" /> </xsl:variable> <CATEGORY ID="{$category}" TITLE="{@CategoryTitle}"> <xsl:for-each select="//XML_OUTPUT[@CategoryID=$category and @UserID=$user]"> <CONTENT_ITEM ID="{@ContentItemID}" TITLE="{@ItemTitle}"> </CONTENT_ITEM> </xsl:for-each> </CATEGORY> </xsl:for-each> </USER> </xsl:for-each> </ROOT> </xsl:template> </xsl:stylesheet> Cheers RH At 09:35 AM 2/11/02 +0200, you wrote: Hi, 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
|