This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Grouping using a Child Node....


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>

Cheers
Vasu


From: "Prince Ohilip" <rajavintemakan@rediffmail.com>
Reply-To: xsl-list@lists.mulberrytech.com
To: XSL-List@lists.mulberrytech.com
Subject: [xsl] Grouping using a Child Node....
Date: 22 Jun 2002 06:04:05 -0000

Hi,
I have a Requirement in which i have to do grouping of Parent Nodes based on a child node value

For Eg:
If i have an XML like
<items>
<item>
<type>A</type>
<name>one</name>
<value>100</value>
</item>
<item>
<type>A</type>
<name>three</name>
<value>300</value>
</item>

<item>
<type>B</type>
<name>four</name>
<value>100</value>
</item>

<item>
<type>B</type>
<name>five</name>
<value>300</value>
</item>
<item>
<type>A</type>
<name>six</name>
<value>100</value>
</item>
</items>

I want to create a XSL for Generating an HTML Table grouped by Type

Table will be like

ItemName Value
Type -A
one 100
Three 300
Six 100

Type - B
four 100
five 300


Thanks

_________________________________________________________
There is always a better job for you at Monsterindia.com.
Go now http://monsterindia.com/rediffin/


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]