gpt4 book ai didi

xml - 两个 sibling 的执行顺序是否依赖?

转载 作者:数据小太阳 更新时间:2023-10-29 02:53:21 26 4
gpt4 key购买 nike

如果我有这样一个 XML 文档:

<people>
<person>
<name> Mario </name>
<age> 25 </age>
</person>
<person>
<name> Lucas </name>
<age> 32 </age>
</person>
</people>

总是保证在文档顺序中,马里奥出现在卢卡斯之前?所以 Lucas 始终是 Mario 的下一个 sibling ,还是依赖于实现?

最佳答案

与属性不同,where order is insignificant根据XML Recommendation :

Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.

元素顺序在 XML 中很重要

然而,令人惊讶的是,XML Recommendation 没有就一般元素顺序的重要性做出明确、明确的声明。语法暗示元素顺序很重要,但与属性不同的是,没有关于元素顺序重要性的明确声明。

following statementElement Type Declarations的情况下:

Definition: In this case, the constraint includes a content model, a simple grammar governing the allowed types of the child elements and the order in which they are allowed to appear.

但这是对 DTD 元素类型声明的引用。 XSD 可以类似地声明排序对于文档有效性而言是重要的(通过 xsd:sequence)或无关紧要的(通过 xsd:all)。对于任何给定的应用程序,顺序可能仍然重要,也可能无关紧要——这取决于应用程序。 [感谢@C。 M. Sperberg-McQueen 对有效性相关性与任何给定应用程序目的相关性差异的有益澄清。]

元素排序的重要性在 XML Information Set Recommendation 中有说明。在 Section 2.2 Element Information Items :

An element information item has the following properties:

[...]

  1. [children] An ordered list of child information items, in document order. This list contains element, processing instruction, unexpanded entity reference, character, and comment information items, one for each element, processing instruction, reference to an unprocessed external entity, data character, and comment appearing immediately within the current element. If the element is empty, this list has no members.

关于xml - 两个 sibling 的执行顺序是否依赖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28268696/

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