I have the following in my xslt file:
<xsl:param name="predicate" select="//Event" />
<xsl:apply-templates select="$predicate" />
And this works fine, but now I’d like to change the param from my .net code.
var args = new XsltArgumentList();
args.AddParam("predicate", "", "//Event[@valid]");
xmlviewer.TransformArgumentList = args;
but no matter what i pass in for predicate, I get the error “Expression must evaluate to a node set.”
Is there a way to pass the xpath selector into the transform?
You are passing just a string to the stylesheet, but the stylesheet is using the
predicateparameter as a node-set — it performs an<xsl:apply-templates>on it.The solution
Evaluate the XPath expression you are now passing as a string. For example, use the
Select()method of XPathNavigator. Then pass as parameter to the transformation the resulting XPathNodeIterator.