是否可以在循环内访问父节点?

发布于 2024-10-03 00:41:58 字数 224 浏览 0 评论 0原文

我有一个像这样的循环:

for $a in local:distinct-nodes($x/input/book[@stat = 'ok'])
let $b:=string($a/../input/@docid)

这返回一个空字符串($b 为空)。所以,我想知道在这种情况下如何访问父节点。我真的不想从 root (//xxxx) 访问它,因为 XML 文件非常大。

I have a loop like this:

for $a in local:distinct-nodes($x/input/book[@stat = 'ok'])
let $b:=string($a/../input/@docid)

This returns an empty string($b is empty). So, I am wondering how I can access the parent node in this situation. I do not really want to access it from root (//xxxx) cause the XML file is quite large.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半衾梦 2024-10-10 00:41:58

我有一个这样的循环:

 for $a in local:distinct-nodes($x/input/book[@stat = 'ok']) 
 让 $b:=string($a/../input/@docid) 

这将返回一个空字符串($b
空)。

是的,这就是应该生产的。

所有 $a 节点都是 book 元素。

$a/..  

input 元素

$a/../input

应该是 input/input 元素,但很可能 input 元素没有 input 子元素。

你想要的是

$a/../@docid

I have a loop like this:

 for $a in local:distinct-nodes($x/input/book[@stat = 'ok']) 
 let $b:=string($a/../input/@docid) 

This returns an empty string($b is
empty).

Yes, this is what should be produced.

All $a nodes are book elements.

$a/..  

are input elements

$a/../input

should be input/input elements, but most probably input elements dont have input children.

What you want is:

$a/../@docid
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文