xsl:其他xsl标签的xpath值变量 [英] xsl:variable as xpath value for other xsl tag

查看:121
本文介绍了xsl:其他xsl标签的xpath值变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题与 xsl:variable 。我想创建一个取决于另一个XML节点属性值的值的变量。这个工作好。但是当我尝试创建一个带有表示XPath的字符串值的变量时,当我尝试在后来的XSL标签中将其用作XPath时,它不起作用。

I'm having issues with xsl:variable. I want to create a variable with a value that depends on the value of another XML node attribute. This working good. But when I try to create a variable with a string value that represents XPath, it just doesn't work when I try to use it as XPath in a later XSL tag.

<xsl:variable name="test">  
  <xsl:choose>
    <xsl:when test="node/@attribute=0">string/represent/xpath/1</xsl:when>
    <xsl:otherwise>string/represent/xpath/2</xsl:otherwise>
  </xsl:choose>       
</xsl:variable>                 
<xsl:for-each select="$test">
  [...]
</xsl:for-each>

我试过:
如何在xsl中使用xsl变量,如果$

使用xsl:for-each选择使用xsl:变量。但是没有结果。

I tried: How to use xsl variable in xsl if and trouble with xsl:for-each selection using xsl:variable. But with no results.

推荐答案

如果这些路径像这种情况提前知道,那么你可以使用:

If those path are known in advance like this case, then you can use:

<xsl:variable name="vCondition" select="node/@attribute = 0"/>
<xsl:variable name="test" select="actual/path[$vCondition] |
                                  other/actual/path[not($vCondition)]"/>

这篇关于xsl:其他xsl标签的xpath值变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆