Subject: Re: [xsl] grouping content From: Dan Diebolt <dandiebolt@xxxxxxxxx> Date: Thu, 5 Apr 2001 18:28:31 -0700 (PDT) |
First of all, you need to close all of your Location tags: <Location Area="A" Value="23"/> Play with the enclosed files. It is just a variant of an recent grouping problem (they seem to appear daily now). Regards, Dan ************************** File: LocationGroups.xml <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="LocationGroups.xsl"?> <root> <Location Area="A" Value="23"/> <Location Area="A" Value="24"/> <Location Area="A" Value="45"/> <Location Area="A" Value="88"/> <Location Area="B" Value="38"/> <Location Area="B" Value="18"/> <Location Area="C" Value="241"/> <Location Area="C" Value="213"/> </root> File: LocationGroups.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="LocationGroups" match="Location" use="@Area"/> <xsl:template match="/"> <xsl:for-each select="root/Location[@Area and generate-id(.)=generate-id(key('LocationGroups',@Area))]"> <xsl:variable name="group" select="@Area"/> Location <xsl:value-of select="$group"/><br/> <xsl:for-each select="/root/Location[@Area=$group]"> ·<xsl:value-of select="@Value"/><br/> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="LocationGroups" match="Location" use="@Area"/> <xsl:template match="/"> <xsl:for-each select="root/Location[@Area and generate-id(.)=generate-id(key('LocationGroups',@Area))]"> <xsl:variable name="group" select="@Area"/> Location <xsl:value-of select="$group"/><br/> <xsl:for-each select="/root/Location[@Area=$group]"> ·<xsl:value-of select="@Value"/><br/> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] grouping content, Jeni Tennison | Thread | [xsl] grouping content, Yang |
RE: [xsl] grouping content, Tim Watts | Date | [xsl] grouping content, Yang |
Month |