[xsl] Re: Re: Re: Create a node set and then apply a template to it

Subject: [xsl] Re: Re: Re: Create a node set and then apply a template to it
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 29 Apr 2002 10:39:11 -0700 (PDT)
> I must be missing something (not a big surprise) ... when I run the 
> sample code you supplied I get the following XSLT error:
>
>     Can not convert #RTREEFRAG to a NodeList!

Hi Paul,

You're not missing anything -- I missed to provide the latest version
of some templates. I discovered too late that one should not test with
MSXML3 -- it allowes an RTF to be passed as parameter and then
processed as node-set (MSXML4 usually crashes on this...)

I don't know when I'll be uploading a new version of FXSL, there are a
few templates that have been updated -- in case someone needs them,
please let me know and I'll send them to you personally.

I think that if you use the corrected str-foldl (bellow), the example I
sent to you should run OK -- it runs for me with MSXML4, MSXML3 and
Saxon 6.5 (I don't have Xalan installed).

Here's the corrected version of str-foldl.xsl:

<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:vendor="urn:schemas-microsoft-com:xslt" 
 exclude-result-prefixes="xsl vendor"
>
    <xsl:template name="str-foldl">
      <xsl:param name="pFunc" select="/.."/>
      <xsl:param name="pA0"/>
      <xsl:param name="pStr"/>

      <xsl:choose>
         <xsl:when test="not(string($pStr))">
            <xsl:copy-of select="$pA0"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:variable name="vFunResult">
              <xsl:apply-templates select="$pFunc[1]">
                <xsl:with-param name="arg0" 
                                select="$pFunc[position() > 1]"/>
                <xsl:with-param name="arg1" select="$pA0"/>
                <xsl:with-param name="arg2" 
                                select="substring($pStr,1,1)"/>
              </xsl:apply-templates>
            </xsl:variable>

            <xsl:call-template name="str-foldl">
      		<xsl:with-param name="pFunc" select="$pFunc"/>
      		<xsl:with-param name="pStr" 
                                select="substring($pStr,2)"/>
      		<xsl:with-param name="pA0" 
                  select="vendor:node-set($vFunResult)"/>
            </xsl:call-template>
         </xsl:otherwise>
      </xsl:choose>

    </xsl:template>
</xsl:stylesheet>


Please, do not hesitate to contact me personally, in case you might
have other problems.

Cheers,
Dimitre Novatchev.


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

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


Current Thread