在 XML 中,原子节点与叶节点相同吗?
我正在 W3Schools 网站上学习有关 XML 的教程。这是我所在的页面:http://www.w3schools.com/xsl/xquery_terms。 asp
我对原子节点和叶节点之间的区别有点困惑。它们是同一件事吗?我知道叶节点是没有任何子节点的节点,但给定示例中的原子节点似乎也没有任何子节点。
W3Schools 网站称“原子值是没有子节点或父节点的节点”。当然,节点不可能没有父节点,因为 XML 文档中的所有节点都必须位于根节点(文档根)下?
谁能向我解释一下,因为我很困惑。
谢谢。
I am working through a tutorial on the W3Schools website about XML. This is the page I'm on: http://www.w3schools.com/xsl/xquery_terms.asp
I'm a bit confused about the difference between an atomic node and a leaf node. Are they the same thing? I know that a leaf node is a node without any children, but it also seems that the atomic nodes in the given example don't have any children either.
The W3Schools site says "Atomic values are nodes with no children or parent." Surely it's impossible for a node not to have a parent, as all the nodes in an XML document have to come under the root node (the document root)?
Can anyone explain this to me as I'm confused.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现 w3schools 通常是查找我曾经知道但忘记的信息详细信息的有用资源,但对于学习新概念而言,它是一个非常糟糕的资源。这个例子很典型:“原子值是没有子节点或父节点的节点。”。错了,完全错了。原子值不是节点。在XQuery使用的XDM模型中,有两种项目:节点和原子值。我建议您使用其他资源,这样不会因提供错误信息而造成不必要的混乱。
I find that w3schools is often a useful resource for looking up details of information that I knew once but had forgotten, but it's a very poor resource for learning new concepts. This example is typical: "Atomic values are nodes with no children or parent.". Wrong, totally wrong. Atomic values are not nodes. In the XDM model used by XQuery, there are two kinds of item, nodes and atomic values. I suggest you use a different resource that isn't going to cause unnecessary confusion by giving wrong information.
在 XQuery 数据模型中,原子值不是节点。它是一个用原子类型标记的值。
因此,节点(甚至叶节点)永远不是原子值,就像原子值永远不是节点一样。但是,节点可以“原子化”为原子值,在这种情况下,将采用其类型化值(如果有的话)。
In the XQuery Data Model, an atomic value is not a node. It is a value labeled with an atomic type.
Hence, a node (even a leaf node) is never an atomic value, just like an atomic value is never a node. However, a node can be "atomized" to an atomic value, in which case its typed value is taken (if it has any).
该示例表明“J K. Rowling”是原子的。
它没有父母,也没有孩子。它本身只是一个值或一个节点。
(想象一个只有该行的文本文件)
但是这个:
J K. Rowling
,有一个父级和一个子级。* 父级:作者
* 孩子:J·K·罗琳
作者可能没有父级,但它不是原子的,因为它有一个子级。
J K. Rowling 可能没有孩子,但它不是原子的,因为它有父母。
同时,叶节点没有子节点,但它可能有也可能没有父节点。
所以总的来说,原子节点只是叶节点的子集。
The example shows that "J K. Rowling" is atomic.
It has no parent, and no child. It's just a value or a node in itself.
(Imagine a text file with just that line)
But this:
<author>J K. Rowling</author>
, has a parent and a child.* Parent: author
* Child: J K. Rowling
Author may have no parent, but it is not atomic since it has a child.
J K. Rowling may have no child, but it is not atomic since it has a parent.
Meanwhile, a leaf node as no child, but it may or may not have a parent.
So overall, an atomic node is just a subset of a leaf node.