Subject: [xsl] Re: Grouping and conditional info questions From: "Yang" <sfyang@xxxxxxxxxxxxx> Date: Sat, 25 Aug 2001 16:11:34 +0800 |
Hi, Ying Qin The following xslt may be one of your solutions. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:key name="item" match="item" use="id" /> <xsl:template match="/"> <groups> <xsl:for-each select="docs/item[count(.|key('item', id)[1]) = 1]"> <group> <title><xsl:text>Group</xsl:text> <xsl:number value="position()" format=" A"/> </title> <xsl:for-each select="key('item', id)"> <item> <xsl:copy-of select="*"/> </item> </xsl:for-each> <xsl:text>
</xsl:text> </group> </xsl:for-each> </groups> </xsl:template> </xsl:stylesheet> Basically, your problem is a typical group method, which Jeni Tennison is one of the best to illustrate the solution for this kind of method. One of her most most recent post is on http://sources.redhat.com/ml/xsl-list/2001-08/msg01289.html(title:grouping headers) I highly recommend you to read this one and her web site. It will help yourself a lot to be familiar with the subject about how to solve the group problem using key and Muenchian method. Besides, copy-of is to copy child node of item, and xsl:number to get your desired title name. Hope it will help. cheers. Sun-fu Yang, sfyang@xxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] jfor: XSL-FO to RTF converter, Bertrand Delacretaz | Thread | [xsl] selecting node with longest d, Mayura Malagala |
[xsl] jfor: XSL-FO to RTF converter, Bertrand Delacretaz | Date | [xsl] selecting node with longest d, Mayura Malagala |
Month |