xsl-list
[Top] [All Lists]

RE: Re: Can not convert #STRING to a NodeList! Error..

2003-11-08 12:12:09

In my child templates, I am retrieving using
    <xsl:param name="labelsfile"/>

This declares an xsl:param element named "labelsfile", whose 
type is not node-set.

Therefore, any attempt to use this as a node-set (e.g. by 
specifying it as the value of the "select" attribute of 
xsl:for-each) will cause a compile-time error.

The solution is to declare the xsl:param in such a way so 
that its type will also be specified to be node-set:

     <xsl:param name="labelsfile" select="/.."/>

This declares the xsl:param to be of type node-set and to 
have as initial value the empty node-set (because the root 
node does not have a parent). Now the compiler "knows" that 
this xsl:param is of type node-set and will not raise a type error.

I'm surprised at this explanation. XSLT 1.0 has no notion of the static
or compile-time type of a variable, all typing is done dynamically at
run-time. Declaring a default value for this parameter should make no
difference to anything unless the template is called without a
parameter.

The code we were shown looks perfectly OK to me.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list