RE: [xsl] Can not convert number to a NodeList

Subject: RE: [xsl] Can not convert number to a NodeList
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 11 Jun 2005 21:21:54 +0100
The expression in the select attribute of xsl:for-each must (in XSLT 1.0) be
a node-set. It can't be a number. 

In XSLT 2.0 you can say

<xsl:for-each select="1 to $line">

to select a sequence of numbers.

In XSLT 1.0, the "proper" way to do something a fixed number of times is a
recursive template. But the following technique is often used as a
workaround, provided the source document contains at least $line (or
$column) nodes:

 <xsl:for-each select="(//node())[position() &lt;= $line]">
  	<xsl:for-each select="(//node())[position() &lt;= $column]">
  		<td><xsl:text>C</xsl:text></td>
  	</xsl:for-each> 

Michael Kay
http://www.saxonica.com/



> -----Original Message-----
> From: Carlos M. S. Bento Nogueira [mailto:cmsbn@xxxxxxxxxxxxxxxxx] 
> Sent: 11 June 2005 19:58
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Can not convert number to a NodeList
> 
> Hi everyone. I'm trying to put this simple cycle to work :
> 
> <xsl:for-each select="$line">
>  	<xsl:for-each select="$column">
>  		<td><xsl:text>C</xsl:text></td>
>  	</xsl:for-each>
> 
>  	<xsl:if test="$line&gt;1">
>  		<tr><xsl:text>L</xsl:text></tr>
>  	</xsl:if>
> </xsl:for-each>
> 
> but i'm always getting an exception: Can not convert number 
> to a NodeList 
> .
> Yes this variables are numbers that must be passed to my xsl file.
> I'm initializing them this way
> <xsl:variable name="column" select="number(fi:styling/@column")/>
> .
> 
> Any ideas how to workaround this? I've tried exslt.org but 
> haven't found
> what i needed.
> 
> TIA,
> CarlosN.

Current Thread