Subject: Re: [xsl] 2 level Grouping through attributes From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 11 Feb 2002 21:13:59 -0500 |
I am trying to achieve multi level grouping (actually two levels) of the next XML.
How can I achieve this?
T:\ftemp>type yoav.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/"> <ROOT> <xsl:variable name="users" select="ROOT/XML_OUTPUT"/> <xsl:for-each select="$users"> <xsl:if test="generate-id(.)= generate-id($users[@UserID=current()/@UserID])"> <USER ID="{@UserID}" NAME="{@UserName}"> <xsl:variable name="categories" select="$users[@UserID=current()/@UserID]"/> <xsl:for-each select="$categories"> <xsl:if test="generate-id(.)= generate-id($categories[@CategoryID= current()/@CategoryID])"> <CATEGORY ID="{@CategoryID}" TITLE="{@CategoryTitle}"> <xsl:for-each select="$categories[@CategoryID= current()/@CategoryID]"> <CONTENT_ITEM ID="{@ContentItemID}" TITLE="{@ItemTitle}"/> </xsl:for-each> </CATEGORY> </xsl:if> </xsl:for-each> </USER> </xsl:if> </xsl:for-each> </ROOT> </xsl:template>
T:\ftemp>xt yoav.xml yoav.xsl <?xml version="1.0" encoding="utf-8"?> <ROOT> <USER ID="3" NAME="Mark"> <CATEGORY ID="1" TITLE="Category A"> <CONTENT_ITEM ID="1" TITLE="Title 1"/> </CATEGORY> <CATEGORY ID="5" TITLE="Category B"> <CONTENT_ITEM ID="45" TITLE="Title 45"/> <CONTENT_ITEM ID="10" TITLE="Title 10"/> <CONTENT_ITEM ID="11" TITLE="Title 11"/> <CONTENT_ITEM ID="12" TITLE="Title 12"/> </CATEGORY> </USER> <USER ID="4" NAME="Joe"> <CATEGORY ID="6" TITLE="Category C"> <CONTENT_ITEM ID="16" TITLE="Title 16"/> <CONTENT_ITEM ID="13" TITLE="Title 13"/> <CONTENT_ITEM ID="15" TITLE="Title 15"/> </CATEGORY> <CATEGORY ID="10" TITLE="Category E"> <CONTENT_ITEM ID="18" TITLE="Title 18"/> <CONTENT_ITEM ID="19" TITLE="Title 19"/> </CATEGORY> </USER> </ROOT>
-- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO - Feb 18-22, 2002
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT & XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed), articles, training(instructor-live,Internet-live,web/CD,licensed) Next public training: 2002-02-13,14,15,18,21,03-04,05,06,11,15, - 04-08,09,10,11,05-06,07,09,10,14,15,06-04,07,10,11,13,14
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] 2 level Grouping through , Jeni Tennison | Thread | [xsl] txt -> xml, Jakub . Valenta |
Re: [xsl] XSLT Whitespace ???, Joerg Heinicke | Date | Re: [xsl] XSLT Whitespace ???, Mike Brown |
Month |