[Home] [By Thread] [By Date] [Recent Entries]
Hi Dennis, If you solve this problem using Muenchian method (as explained by Wendell), it'll be very efficient. But here is a solution, which is not efficient as the Muenchian method, but this is probably how a layman would think to solve this problem. The logic is quite simple, and only needs one to know how preceding-sibling axis works. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" /> <xsl:template match="/examples">
<html>
<head>
<title/>
</head>
<body>
<table>
<tr>
<th>Catagory</th>
<th>Year</th>
</tr>
<xsl:for-each select="example[not(concat(category, year) =
concat(preceding-sibling::example/category,
preceding-sibling::example/year))]">
<xsl:sort select="category" />
<xsl:sort select="year" data-type="number" />
<tr>
<td><xsl:value-of select="category" /></td>
<td><xsl:value-of select="year" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet> This when applied to XML: <examples> <example> <category>XML</category> <year>2005</year> </example> <example> <category>XSL</category> <year>2005</year> </example> <example> <category>XSL</category> <year>2006</year> </example> <example> <category>XML</category> <year>2005</year> </example> </examples> Produces output: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<table>
<tr>
<th>Catagory</th>
<th>Year</th>
</tr>
<tr>
<td>XML</td>
<td>2005</td>
</tr>
<tr>
<td>XSL</td>
<td>2005</td>
</tr>
<tr>
<td>XSL</td>
<td>2006</td>
</tr>
</table>
</body>
</html>On 8/15/06, Stinissen, Dennis <D.Stinissen@xxxxxxxxx> wrote: Hi,
http://gandhimukul.tripod.com
|

Cart



