在迭代中使用 xf:setvalue 函数时如何引用位置

How to refer to position when using xf:setvalue function with iterate

考虑到这个 code example and this post

...
<xf:action>
<xf:setvalue
            iterate="instance('fr-send-submission-params')/@*"
            ref="."
            value="event(name(context()))"/>
</xf:action>
...

如何引用当前迭代位置?喜欢value="position()"

我可以使用这个位置作为 xpath 表达式的变量吗?喜欢ref="/AnotherElement[position()]"

以下作品:

<xf:action iterate="instance('fr-send-submission-params')/@*">
    <xf:var name="p" value="position()"/>
    <xf:setvalue ref="." value="$p"/>
</xf:action>

我认为您不能只使用 xf:setvalue,因为 ref 将表达式的求值上下文更改为单个项目,这意味着 position() returns 1 value.

当我看到您对属性进行迭代时发出的警告:我认为不能保证属性位置是一致的。

更新:

如果您有元素,则以下内容有效,但您需要了解 xf:setvalue 中迭代的项目:

<xf:setvalue
    event="DOMActivate"
    iterate="value"
    ref="."
    value="count(preceding-sibling::value) + 1"/>

所以我认为带有封闭动作的选项更清晰。