xsl-list
[Top] [All Lists]

Re: Pass node to template

2003-05-20 13:04:38
Scope?

Its still not working, all though I was able to get the suggested change to
the "with-param select" to work but only in a test environment.  I am
wondering if I am losing scope.  So let me ask this:

Does a variable not have scope inside an xsl:choose block if the variable
was declared outside of this in an xsl:for-each block?  So (not syntactily
correct):
<xsl:for-each>
    <xsl:variable name="some_variable" select="some_node">
    <xsl:choose>
        <xsl:when test="....">
        <xsl:value-of select="some_variable">
        </xsl:when>
    </xsl:choose>
</xsl:for-each>

Then, take this one step further and from within the above "choose", call a
template passing this node set.  Would this template then loose scope do the
nature of the variable being passed down through scope (like the above
example)?

Karl


----- Original Message -----
From: "Michael Kay" <mhk(_at_)mhk(_dot_)me(_dot_)uk>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Tuesday, May 20, 2003 12:41 PM
Subject: RE: [xsl] Pass node to template


<xsl:value-of> extracts the string value of a node; you want to pass the
node itself.

Instead of

<xsl:with-param name="nodEdit"><xsl:value-of select="$EDITPROP"
/></xsl:with-param>

you want

<xsl:with-param name="nodEdit" select="$EDITPROP" />

Michael Kay


-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Karl J. Stubsjoen
Sent: 20 May 2003 16:30
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Pass node to template


Hello,

I am having difficulties passing a node to a named template.
Similar tests on the node (as a variable) work fine inline
where it was created.  However, trying to pass it to a named
template and then performing identical steps yields the error:

msxml4.dll error '80004005'
Reference to variable or parameter 'nodEdit' must evaluate to
a node list.

Here is where I set my node variable:

    <xsl:variable name="EDITPROP" select="EDITPROPS"/>
    <xsl:value-of select="$EDITPROP/@type"/>

    <!-- (notice the value-of, it my test and it works perfect) -->


Here is my call ($EDITPROP is the node):

             <xsl:call-template name="MAKE_INPUT_BOX">
                <xsl:with-param
name="input_name"><xsl:value-of select="$innerFLD"/></xsl:with-param>
                <xsl:with-param
name="input_value"><xsl:value-of select="$currentVAL"
/></xsl:with-param>
                <xsl:with-param name="nodEdit"><xsl:value-of
select="$EDITPROP" /></xsl:with-param>
                </xsl:call-template>

Here is the beginning part of my template that fails:
<xsl:template name="MAKE_INPUT_BOX"> <xsl:param
name="input_name"/> <xsl:param name="input_value"/>
<xsl:param name="nodEdit"/>

    <xsl:value-of select="$nodEdit/@type"/>

    <!-- (this value-of causes an error) -->

So what am I doing wrong?
Thanks for the help.
Karl


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



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





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



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