![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Displaying a table column by column [Thread Next] Re: Displaying a table column by columnTo: NULL Date: 2/14/2007 7:01:00 PM
cedric.louyot@g... wrote:
> I've just found another solution which is a bit different from yours :
>
> <table>
> <tbody>
> <xsl:for-each select="col[1]/line">
> <xsl:variable name="numLine" select="position()"/>
> <tr>
> <xsl:for-each select="../../col">
> <xsl:variable name="numCol" select="position()"/>
> <td>
> <xsl:value-of select="."/>
> </td>
> </xsl:for-each>
> </tr>
> </xsl:for-each>
> </tbody>
> </table>
>
> You use templates (whereas I don't) which makes your solution
> clearer.
> However you use the following-sibling axes and I don't use it (I use
> another xsl:variable instead).
> Can you help me figure out which of the 2 solutions (yours and mine)
> is the best and why.
If you want your approach (which walks up to the grand parent and then
looks at all col children instead of my attempt which looks at all
sibling col elements) then you can use e.g.
<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="../../col/line[$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 | |||||
|
