![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Displaying a table column by column >Thread Next - Re: Displaying a table column by column Re: Displaying a table column by columnTo: NULL Date: 2/14/2007 5:02:00 PM
cedric.louyot@g... wrote:
> I have an xml file looking like :
> <col>
> <line>11</line>
> <line>21</line>
> </col>
> <col>
> <line>12</line>
> <line>22</line>
> </col>
> But I need to print out (printed column by column):
> 11 12
> 21 22
Here is an example stylesheet:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html lang="en">
<head>
<title>table example</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="/*">
<table>
<tbody>
<xsl:apply-templates select="col[1]/line" mode="row"/>
</tbody>
</table>
</xsl:template>
<xsl:template match="line" mode="row">
<xsl:variable name="row-number" select="position()"/>
<tr>
<xsl:apply-templates select=". |
../following-sibling::col/line[position() = $row-number]" mode="cell"/>
</tr>
</xsl:template>
<xsl:template match="line" mode="cell">
<td><xsl:value-of select="."/></td>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
