Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Looping through nodes. [Thread Next] Re: Looping through nodes.To: NULL Date: 11/5/2004 5:22:00 PM
ajit goel wrote:
> I want HTML output.
Here is a stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" encoding="UTF-8" />
<xsl:template match="/">
<html>
<head>
<title>customer list</title>
</head>
<body>
<xsl:variable name="customerCount"
select="count(customers/customer)" />
<xsl:variable name="colLength" select="round($customerCount div
2)" />
<xsl:if test="$customerCount > 0">
<table border="1">
<tbody>
<xsl:for-each select="customers/customer[position() <=
$colLength]">
<tr>
<td><xsl:value-of select="name" /></td>
<td><xsl:value-of
select="following-sibling::customer[$colLength]/name" /></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:if>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output is
<table border="1">
<tbody>
<tr>
<td>First</td><td>Fourth</td>
</tr>
<tr>
<td>Second</td><td>Fifth</td>
</tr>
<tr>
<td>Third</td><td></td>
</tr>
</tbody>
</table>
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
