是否可以使用.NET 2.0 XSLT實現動態評估XPath變量字符串?

[英]Is dynamic evaluation of XPath variable string possible using .NET 2.0 XSLT implementation?


I'm trying to evaluate an XPath varable I'm building dynamically based on the position of the node.

我正在嘗試評估一個XPath varable,我根據節點的位置動態構建。

I can create the XPath string in a variable but when I select the value of this just get the string and not the node set I need.

我可以在變量中創建XPath字符串,但是當我選擇它的值時,只需獲取字符串而不是我需要的節點集。

I use the following to create the XPath query.

我使用以下命令創建XPath查詢。

<xsl:variable name="xpathstring" 
              select="normalize-space(concat(&quot;//anAttribute[@key='pos&quot;,position(),&quot;']&quot;))"/>

And try to output the value with the following.

並嘗試使用以下輸出值。

<xsl:value-of select="$xpathstring"/>

If I execute the XPath query in my debugger I get the nodeset but in my XML output only get the XPath string which looks like this //anAttribute[@key='pos1'].

如果我在我的調試器中執行XPath查詢,我得到了節點集,但是在我的XML輸出中只獲得了看起來像這樣的//一個字符串[anAttribute [@ key ='pos1']。

I had a look at exslt dyn:evaluate which seems to enable this but this seems to be only supported by certain processors and doesn't provide a standalone implementation or at least as far as I could see (currently using the standard .NET 2.0 XSLT which is only XSLT 1.0 as far as I recall.)

我看看exslt dyn:evaluate似乎啟用了這個但是這似乎只支持某些處理器並且不提供獨立的實現或至少我能看到(目前使用標准的.NET 2.0 XSLT)據我所知,這只是XSLT 1.0。)

Is there any way to handle this without changing processor?

有沒有辦法處理這個而不改變處理器?

1 个解决方案

#1


1  

Why do you not use a param instead of the concatenation:

為什么不使用參數而不是串聯:

<xsl:param name="pos">
    <xsl:text>pos</xsl:text>
    <xsl:value-of select="position()"/>
</xsl:param>
<xsl:value-of select="//anAttribute[@key=$pos]"/>

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/03/13/7298383808e9c26abb7c97c41909ac5d.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com