|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Grouping and Unique Lists
Hi,
I have not tried this with IE5 but this works for me and produces exactly
the output you specified... FYI I created and previewed this using the
Stylus beta editor and then tested it with Oracle's XMLparser.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
<xsl:template match="ITEMLIST">
<xsl:apply-templates select="ITEM"/>
</xsl:template>
<xsl:template match="ITEM">
<xsl:if test =
"not(CATEGORY=preceding-sibling::ITEM[position()=1]/CATEGORY)">
<xsl:value-of select="CATEGORY"/><br/>
</xsl:if>
<xsl:value-of select="NUMBER"/>
<xsl:text> </xsl:text>
<xsl:value-of select="DESCRIPTION"/><br/>
</xsl:template>
</xsl:stylesheet>
regards
Richard Sargeant
-----Original Message-----
From: Michael J. Dyer [mailto:michael.dyer@xxxxxxxxxx]
Sent: Monday, September 27, 1999 19:04
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Grouping and Unique Lists
I've searched the archives and found a few posts in this area, but nothing
that seems to directly address the problem. I'm working with the Microsoft
IE5 XMLDom. Given the following XML:
<?XML version='1.0'?>
<ITEMLIST>
<ITEM>
<CATEGORY>Category A</CATEGORY>
<NUMBER>00001</NUMBER>
<DESCRIPTION>Item 1</DESCRIPTION>
</ITEM>
<ITEM>
<CATEGORY>Category B</CATEGORY>
<NUMBER>00002</NUMBER>
<DESCRIPTION>Item 2</DESCRIPTION>
</ITEM>
<ITEM>
<CATEGORY>Category B</CATEGORY>
<NUMBER>00003</NUMBER>
<DESCRIPTION>Item 3</DESCRIPTION>
</ITEM>
<ITEM>
<CATEGORY>Category C</CATEGORY>
<NUMBER>00004</NUMBER>
<DESCRIPTION>Item 4</DESCRIPTION>
</ITEM>
</ITEMLIST>
1. Using XSL, convert to the following output (without using the actual
category name as part of the XSL)
Category A
00001 Item 1
Category B
00002 Item 2
00003 Item 3
Category C
00004 Item 4
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
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








