gpt4 book ai didi

xpath - 在 current-group() 上使用 XPath

转载 作者:行者123 更新时间:2023-12-03 17:09:33 24 4
gpt4 key购买 nike

我需要选择 current-group() 的 a 的节点子集在 xsl:for-each-group环形。当我使用 current-group()/foo 形式的 XPath 时, 没有匹配的。但是,如果我将当前组绑定(bind)到一个变量,如下所示:

<xsl:variable name="foo"><xsl:copy-of select="current-group()"/></xsl:variable>

然后使用 $foo/foo 形式的 XPath ,我得到了预期的匹配。我怀疑这个问题与 current-group() 的类型有关。以及如何 $foo变量有不同的类型,但我自己似乎无法弄清楚。有什么线索可以避免引入变量来进行类型转换吗?还是有什么不同?

最佳答案

如果您执行以下操作:<xsl:for-each-group select="foo" group-by="type">
<xsl:value-of select="current-group()[self::foo]"/>
</xsl:for-each-group>
然后current-group()返回元素序列

<xsl:variable name="foo"><xsl:copy-of select="current-group()"/></xsl:variable>
返回一个包含 foo 序列的文档节点,然后你需要使用:<xsl:value-of select="current-group()/foo"/>

关于xpath - 在 current-group() 上使用 XPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50059041/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com