Subject: Re: [xsl] Can I group 3 levels somehow From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 22 Mar 2002 20:42:51 -0500 |
I am trying to group xml elements using three attributes.
i.e.
- Firstly, I want to group them by the imagetype
---- Then within these imagetype groups, group by ordinal
---------- then within imagetype and ordinal I want to groupby imageparentid
Is this possible
T:\ftemp>type gary.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="/"> <xsl:variable name="all-images" select="/article/images/image"/> <xsl:for-each select="$all-images"> <xsl:sort select="@imagetype"/> <xsl:if test="generate-id(.) = generate-id($all-images[@imagetype=current()/@imagetype])"> <xsl:variable name="imagetypes" select="$all-images[@imagetype=current()/@imagetype]"/> <h2>Image Type - <xsl:value-of select="@imagetype"/></h2> <xsl:for-each select="$imagetypes"> <xsl:sort select="@ordinal"/> <xsl:if test="generate-id(.) = generate-id($imagetypes[@ordinal=current()/@ordinal])"> <xsl:variable name="ordinals" select="$imagetypes[@ordinal=current()/@ordinal]"/> <h3>Ordinal - <xsl:value-of select="@ordinal"/></h3> <xsl:for-each select="$ordinals"> <xsl:sort select="@imageparentid"/> <xsl:if test="generate-id(.) = generate-id($ordinals[@imageparentid = current()/@imageparentid])"> <xsl:variable name="imageparentids" select="$ordinals[@imageparentid=current()/@imageparentid]"/> <h4>Image parent id - <xsl:value-of select="@imageparentid"/> </h4> <table border="1"> <xsl:for-each select="$imageparentids"> <tr> <td><xsl:value-of select="@ordinal" /></td> <td><xsl:value-of select="@imgsrc" /></td> <td><xsl:value-of select="@imagex" /></td> <td><xsl:value-of select="@imagey" /></td> <td><xsl:value-of select="@alt" /></td> <td><xsl:value-of select="@imagesize" /></td> <td><xsl:value-of select="@bytesize" /></td> <td><xsl:value-of select="@imageparentid" /></td> <td><xsl:value-of select="@imagetype" /></td> <td><xsl:value-of select="@imageid" /></td> </tr> </xsl:for-each> </table> </xsl:if> </xsl:for-each> </xsl:if> </xsl:for-each> </xsl:if> </xsl:for-each> </xsl:template>
-- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002 - : 3-days XML Information Modeling: July 31-August 2, 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-04-08,09,10,11,05-06,07,09,10,13,20, - 06-04,07,10,11,13,14,17,20,07-31
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Can I group 3 levels somehow, gary cor | Thread | [xsl] templates with optional param, robert . soesemann |
Re: [xsl] FOP - what, where, when, , Jörg Heinicke | Date | [xsl] XSL-based report engines?, Ross Lambert |
Month |