Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
im scratching my head here, hopefully someone can help me out.
Im trying to pass a set of nodes as a parameter to an xslt template. thats about it.
<xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:choose> <xsl:when test="$currentPage/@level=3"> <xsl:call-template name="test"> <xsl:with-param name="nodes"> <xsl:value-of select="$currentPage/../node" /> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="test"> <xsl:with-param name="nodes"> <xsl:value-of select="$currentPage/../../node" /> </xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="test"> <xsl:param name="nodes"></xsl:param> <xsl:value-of select="count($nodes)" /> </xsl:template>
It errors on trying to print out the count of $nodes. Due to this i cant loop through it and do what i need to do. However just outputting $nodes within the test function does output values to the page. What am i doing wrong? :S
Thanks!
You are using xsl:value-of which will just get the value of the node out as a string. Instead you just want to pass the node itself like so
<xsl:call-template name="test"> <xsl:with-param name="nodes" select="$currentPage/../node" /> </xsl:call-template>
Its the difference between passing the value of a node or the node itself.
Hope that sorts it.
thanks very much Peter!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
XSLT - Passing nodes as a parameter to templates
im scratching my head here, hopefully someone can help me out.
Im trying to pass a set of nodes as a parameter to an xslt template. thats about it.
It errors on trying to print out the count of $nodes. Due to this i cant loop through it and do what i need to do. However just outputting $nodes within the test function does output values to the page. What am i doing wrong? :S
Thanks!
You are using xsl:value-of which will just get the value of the node out as a string. Instead you just want to pass the node itself like so
Its the difference between passing the value of a node or the node itself.
Hope that sorts it.
thanks very much Peter!
is working on a reply...