This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Grouping using a Child Node....
- From: Mike Brown <mike at skew dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 24 Jun 2002 03:39:52 -0600 (MDT)
- Subject: Re: [xsl] Grouping using a Child Node....
- Reply-to: xsl-list at lists dot mulberrytech dot com
Vasu Chakkera wrote:
> Prince,
> The following code will help you..
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> <xsl:for-each select="/items/item[not(type=preceding-sibling::item/type)]">
> <b><u><i>The Details of <xsl:value-of select="./type"/></i></u></b><br></br>
> <xsl:for-each select="/items/item[./type = current()/type]">
> <xsl:value-of select="./name"/>--------<xsl:value-of
> select="./value"/><br></br>
> </xsl:for-each>
> <hr></hr>
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
There's no harm in the above, but I thought I'd point out that
- "./" is redundant and can be omitted.
- "<br></br>" & "<hr></hr>" can be shortened to "<br/>" & "<hr/>".
- If the output is to be serialized as HTML, <xsl:output method="html"/>
would be prudent.
- Mike
____________________________________________________________________________
mike j. brown | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list