开发者

xslt test with 2 parameters

开发者 https://www.devze.com 2023-03-24 17:11 出处:网络
<xsl:if test=\"count($currentPage/..//$itemType) &gt; 0\"> I try to use the if statement with 2 param values and I get the error:

<xsl:if test="count($currentPage/..//$itemType) &gt; 0">

I try to use the if statement with 2 param values and I get the error: "unexpec开发者_运维知识库ted token '$' in the expression..."

is it possible to do what I'm trying to ?


In XSLT, like in most programming languages (excluding macro languages), variables represent values, not fragments of expression text. I suspect $itemType holds an element name, and you are imagining that you can use it anywhere you could use an element name. If that's what you are trying to do, use ..//*[name()=$itemType].


This is invalid (and @Michael Kay explained it well):

//$varName

If I guess correctly what you are up to, then you may try this:

//*[name() = $varName]
0

精彩评论

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