The variable named "parm" is a Result Tree Fragment and cannot be
converted to an XSLT node-set.  To get what you want, try

  <xsl:variable name="parm" select="'books'" />

Note the inner quotes on the select attribute making books a string.
For more info on this, see
http://www.w3.org/TR/xslt#section-Result-Tree-Fragments and the
following section.

Gary

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, October 16, 2001 6:27 AM
> To: [EMAIL PROTECTED]
> Subject: variable in select do not work
> 
> 
> Hi everybody,
> I've a problem that I've reproduced with the following  
> stilesheet: The following works:
> 
> <?xml version='1.0'?>
> <xsl:stylesheet version="1.0" xmlns:xsl 
> ="http://www.w3.org/1999/XSL/Transform";>
> 
> <xsl:template match="/">
>     <xsl:apply-templates select="catalog"/>
> </xsl:template>
> 
> <xsl:template match="catalog">
>     <xsl:variable name="books" select="book"/>
>    Number of books: <xsl:value-of select="count($books)"/> 
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> the following give the error: Can not convert #RTREEFRAG to a 
> NodeList!
> 
> <?xml version='1.0'?>
> <xsl:stylesheet version="1.0" xmlns:xsl 
> ="http://www.w3.org/1999/XSL/Transform";>
> 
> <xsl:variable name="parm">book</xsl:variable>
> 
> <xsl:template match="/">
>     <xsl:apply-templates select="catalog"/>
> </xsl:template>
> 
> <xsl:template match="catalog">
>     <xsl:variable name="books" select="$parm"/>
>    Number of books: <xsl:value-of select="count($books)"/> 
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> (See attached file: sample.xml)
> 
> My real code take parm as parameter, but it gives the same 
> error. I was expecting that  <xsl:variable name="books" 
> select="$parm"/> returned a nodset that I could pass to the 
> count() function, but I was wrong!! Any hint?
> 
> thanks a lot Maria
> 

Reply via email to