|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Grouping and conditional info questions
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
|
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
|

Cart








