gpt4 book ai didi

xslt - node-set() 是否有祖先节点?

转载 作者:行者123 更新时间:2023-12-02 15:28:10 24 4
gpt4 key购买 nike

我觉得,这是一个基本的 XSLT 问题。据我了解,节点集本身就是数据结构。从 node-set() 我无法导航到集合之外的任何节点。即我无法到达父级,xml 的开头或其 sibling 。这样对吗?

有没有办法获取节点集的父节点()

代码

<neighbourhood>
<parent name = "xyz">
<child address=10> a </child>
<child address=10> b </child>
<child address=15> c </child>
</parent>
</neighbourhood>

我有一组子节点。我需要消除具有重复“地址”的节点。可以有 n 个“parent”和 m 个“child”,并且可以有一个“child”的祖 parent 节点。

最好和合乎逻辑的方法可能是每个 parent 都去处理他们的 child 。但是,它是一个现有的代码库,这是一个过于简单的示例。我不想通过调用调用函数和其他模板来破坏太多东西。

所以,我的问题是我是否可以用我拥有的“子”节点集获得“父”

谢谢大家的回复

最佳答案

Does node-set() have an ancestor node?

node-set() 是一个(扩展)函数——不是节点。函数不能有祖先,因为它不是节点。

我想问题中的 "node-set()" 是指 xxx:node-set() 函数返回的值(其中前缀“xxx”绑定(bind)到特定于供应商的命名空间)。如果是这样,这是想要的答案:

根据定义,xxx:node-set() 函数返回 document-node()(也称为 root-node in XPath 1.0) 的临时树,通过转换 RTF(结果树片段)获得,作为唯一参数传递给此函数。

根据定义,文档节点位于文档层次结构的顶部,并且是 XML 文档中唯一没有父节点的节点。

因此,调用xxx:node-set() 函数返回的节点没有任何祖先

From a node-set() I cannot navigate to any node that is outside of the set. i.e I cannot reach the parent, the beginning of the xml nor its siblings. Is this right?

是的,无需调用从另一个文档返回节点的另一个函数(例如标准 XPath 函数 id() 或标准 XSLT 函数 document()),或引用变量/参数,仅通过使用 XPath 定位步骤无法从另一个文档导航到节点。

or

Is there a way to get a parent of a node-set()

不,xxx:node-set() 函数返回的节点是文档节点,文档节点没有父(或任何其他祖先)节点。

关于xslt - node-set() 是否有祖先节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29356859/

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