开发者

XSL for-each filtering; how to evaluate TWO variable in select?

<xsl:variable name="filterValue"
 >@subject = 'Subject To Filter On'</xsl:variable>
<xsl:for-e开发者_StackOverflowach select="$Rows[$filterValue]">

It seems to me that the $filterValue is being treated as a literal string rather than being evaluated. How can I make it so that the variable's value is evaluated instead?

Desired result:

<xsl:for-each select="$Rows[@subject = 'Subject To Filter On']">

I apologize if this has been answered before, I don't know much terminology about XSL so I'm having trouble searching online. Thanks.


Dynamic evaluation of XPath expressions is not supported in both XSLT 1.0 and XSLT 2.0.

Usually, there are workarounds.

In this specific case you can have (global/external) parameters:

  <xsl:param name="attrName" select="'subject'"/>
  <xsl:param name="attrValue" select="'Subject To Filter On'"/>

and then in your code:

<xsl:for-each select="$Rows[@*[name()=$attrName] = $attrValue]"> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜