[英]Querying results of msxsl:node-set is not working
I am using the node-set
built-in-function to convert an xsl variable into a nodeset as in the code below 我正在使用
node-set
内置函数将xsl变量转换为节点集,如以下代码所示
<xsl:variable name="allotmentValuesNodeSet" select="msxsl:node-set($allotmentValues)"/>
The command <xsl:copy-of select="$allotmentValuesNodeSet"/>
produces the following output: 命令
<xsl:copy-of select="$allotmentValuesNodeSet"/>
产生以下输出:
<values>
<month>Mar</month>
<incomeQTD>1499.63109246680</incomeQTD>
<realizedQTD />
<incomeYTD>1519.35773710483</incomeYTD>
<realizedYTD />
<incomePrevYTD>1519.35773710483</incomePrevYTD>
<realizedPrevYTD />
<month />
<incomeQTD />
<realizedQTD />
<incomeYTD />
<realizedYTD />
<incomePrevYTD />
<realizedPrevYTD />
</values>
When I try to query the node-set variable with this xsl command <xsl:value-of select="count($allotmentValuesNodeSet/values/month)"/>
I always get 0
, although the result should be 2
. 当我尝试使用此xsl命令
<xsl:value-of select="count($allotmentValuesNodeSet/values/month)"/>
查询节点集变量时,尽管结果应为2
,但我总是得到0
。
The allotmentValues
variable is included between other, outer xml nodes. allotmentValues
变量包含在其他外部xml节点之间。 If I do not include it between any xml nodes, then the code works as expected. 如果我没有在任何xml节点之间包括它,那么代码将按预期工作。
Is there any obvious casue (eg namespace related maybe?) for why querying xsl node-sets might break? 是否存在任何明显的理由(例如,可能与名称空间相关?),为什么查询xsl节点集可能会中断?
If needed, I will try to come up with a simple example to illustrate my problem (I cannot exactly post the code snippet of the issue since it's proprietary code). 如果需要,我将尝试提出一个简单的示例来说明我的问题(由于该问题是专有代码,因此我无法准确发布该问题的代码段)。
使用例如<xsl:variable name="allotmentValues" xmlns="">...</xsl:variable>
以及可能没有前缀的路径<xsl:value-of select="count($allotmentValuesNodeSet/values/month)"/>
作品。
I have found the solution from this question to work in my situation. 我已经找到了解决该问题的方法 ,可以在我的情况下使用。
Brief description of the issue and solution: 问题和解决方案的简要说明:
<xsl:variable/>
from which we derive the node set is included in an xml block with a default namespace, it inherits that namespace <xsl:variable/>
包含在具有默认名称空间的xml块中,则它继承该名称空间 count($allotmentValuesNodeSet/inheritedNS:values/inheritedNSmonth)
instead of count($allotmentValuesNodeSet/values/month)
count($allotmentValuesNodeSet/inheritedNS:values/inheritedNSmonth)
而不是count($allotmentValuesNodeSet/values/month)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.