xsl-list
[Top] [All Lists]

Node-List in Variables

2003-05-02 02:00:59
Hello,

i want to tokenize a string, delimited  with a special character, into its
tokens and want this tokens to be a result-tree which i can handle with an
xsl:for-each.

myexample
the first xsl:variable call the template tokenizer which creates the
t1-elements recursivly for all string elements (a, b and c).
i would expect that the variable tlist contains
<t1>a</t1><t1>b</t1><t1>c</t1> which i then want to work on with the
xsl:for-each, but the xslt-processor gives the error that the expression in
xsl:for-each must evaluate to a node-set. if i use the ms-xslt-nodeset
function i get only one node which contains the textvalues of the elements (
in my example it containt abc). so it seems, that tlist only contains a
string.

any idea what is wrong and how i can achieve my goal?

regards
matthias 


<xsl:variable name="tlist">
        <xsl:call-template name="tokenizer">
                <xsl:with-param name="tokenstr" select="a|b|c|"/>
         </xsl:call-template>
</xsl:variable>

<xsl:for-each select="$tlist">
        <xsl:value-of select="."/>
</xsl:for-each> 


<xsl:template name="tokenizer">
        <xsl:param name="tokenstr"/>
        
        <xsl:variable name="akttoken"
select="normalize-space(substring-before($tokenstr,'|'))"/>
        <xsl:if test="string-length($akttoken) &gt; 0">
                <!-- Ist noch nen Token da -->
                <xsl:element name="t1">
                        <xsl:value-of select="$akttoken"/>
                </xsl:element>
                <xsl:call-template name="tokenizer">
                        <xsl:with-param name="tokenstr"
select="substring-after($tokenstr,'|')"/>
                </xsl:call-template>
        </xsl:if>
</xsl:template>

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



<Prev in Thread] Current Thread [Next in Thread>