<tag/> 之间是否存在语义差异?和<标签></标签>在 XML 中? [英] Is there a semantic difference between <tag /> and <tag></tag> in XML?
问题描述
我们遇到了一个客户的问题,他认为我们发送的 XML 文件中的两个版本的空标签之间存在语义差异(纯 XML 没有 HTML..).
We have some kind of problem with a customer which is arguing that there is a semantical difference between two versions of empty tag in an XML file we're sending (pure XML no HTML..).
他们期望:
<our-xml>
<some-tag></some-tag>
</our-xml>
我们发送:
<our-xml>
<some-tag />
</our-xml>
我们认为这完全一样,但我们无法用事实真正证明这些论点.我们唯一发现的是 https://www.w3.org/TR/REC-xml/#sec-starttags 它说的地方
We are of the opinion that this is exactly the same but we could not really prove the arguments with facts. Only thing we found was in https://www.w3.org/TR/REC-xml/#sec-starttags where it says
空元素标签可以用于任何没有内容的元素.
empty-element tags may be used for any element which has no content.
是否有任何我们可以依赖的讨论或更清晰的论文,或者我们错了吗?
Is there any discussion or more clear paper that we can rely on or are we wrong?
推荐答案
否
开始标签/结束标签(<tag></tag>
)和空元素标签(
No
Start-tag/End-tag (<tag></tag>
) and Empty-element tag (<tag/>
) forms are semantically equivalent. No conforming XML parser will treat them differently.
空元素标签可用于任何没有内容的元素,无论它是否使用关键字 EMPTY 声明.
Empty-element tags may be used for any element which has no content, whether or not it is declared using the keyword EMPTY.
历史记录:还有一个过时的 SGML 兼容性参考,为了完整起见,我将其包括在内:
Historical note: There is also an antiquated SGML compatibility reference, which I include for completeness:
为了互操作性,应该使用空元素标签,并且只能用于声明为 EMPTY 的元素.
For interoperability, the empty-element tag should be used, and should only be used, for elements which are declared EMPTY.
-
为了互操作性
[定义:标记一个描述非约束性建议的句子,以增加 XML 文档可以被现有安装的 SGML 处理器基础处理的机会,该基础早于 ISO 8879 的 WebSGML 适配附件.]
[Definition: Marks a sentence describing a non-binding recommendation included to increase the chances that XML documents can be processed by the existing installed base of SGML processors which predate the WebSGML Adaptations Annex to ISO 8879.]
相关问答:
这篇关于<tag/> 之间是否存在语义差异?和<标签></标签>在 XML 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!