Hey all - this question seems fairly similar to the question at XSLT nodeset question, but that one's a year old and doesn't really answer my question.
I'm trying to pass a set of nodes (actually just one in this case) from one template to another template, using xsl:call-template. But I keep getting "expression must evaluate to a node-set". I'm using msxsl:node-set() to try and convert my "select" into a node set. In this case I could just pass through an id and use that to reinstantiate the (single) node on the other side, but I'd like to know how to do this since there are other cases in my code where I want to pass through more than one node. Any help would be greatly appreciated. :)
When you assign a variable using the select attribute, you don't need to use the node-set() function - it's a perfectly valid node-set already.
In your "SideNavigation_PrintChildren.xslt" file, move the <xsl:param name="printChildrenOf" /> declaration inside of the named template (i.e., 2 lines down) and it should start working.
Thanks heaps Chriztian, that worked a treat. I did some reading on xsl:param, and apparenlty this changes the param from being global to being local. Do parameters to templates I call always have to be local? I'm assuming that global parameters are things that are passed to the "top level" template, and things that that template passes to it's children should be declared as local?
When you do a call-template using with-param, the parameter you reference should be a local param defined in the template you call - but you can pass the value of any global or local variable on to the template. The template itself can also access any globally defined variables/parameters in the stylesheet.
Global parameters have one special feature - they can be set from "The Outside" (i.e., .NET or whichever technology is using the XSLT Processor) - this is how Umbraco passes the $currentPage context into macros.
"Expression must evaluate to a node-set"
Hey all - this question seems fairly similar to the question at XSLT nodeset question, but that one's a year old and doesn't really answer my question.
I'm trying to pass a set of nodes (actually just one in this case) from one template to another template, using xsl:call-template. But I keep getting "expression must evaluate to a node-set". I'm using msxsl:node-set() to try and convert my "select" into a node set. In this case I could just pass through an id and use that to reinstantiate the (single) node on the other side, but I'd like to know how to do this since there are other cases in my code where I want to pass through more than one node. Any help would be greatly appreciated. :)
SideNavigation.xslt:
SideNavigation_PrintChildren.xslt:
Hi George,
When you assign a variable using the select attribute, you don't need to use the node-set() function - it's a perfectly valid node-set already.
In your "SideNavigation_PrintChildren.xslt" file, move the <xsl:param name="printChildrenOf" /> declaration inside of the named template (i.e., 2 lines down) and it should start working.
/Chriztian
Thanks heaps Chriztian, that worked a treat. I did some reading on xsl:param, and apparenlty this changes the param from being global to being local. Do parameters to templates I call always have to be local? I'm assuming that global parameters are things that are passed to the "top level" template, and things that that template passes to it's children should be declared as local?
Hi George,
When you do a call-template using with-param, the parameter you reference should be a local param defined in the template you call - but you can pass the value of any global or local variable on to the template. The template itself can also access any globally defined variables/parameters in the stylesheet.
Global parameters have one special feature - they can be set from "The Outside" (i.e., .NET or whichever technology is using the XSLT Processor) - this is how Umbraco passes the $currentPage context into macros.
/Chriztian
is working on a reply...