<tag/> 之间是否存在语义差异?和<tag></tag>在 XML 中?

编程入门 行业动态 更新时间:2024-10-25 18:26:43
本文介绍了<tag/> 之间是否存在语义差异?和<tag></tag>在 XML 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我们与一位客户遇到了某种问题,该客户认为我们发送的 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/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/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?

推荐答案

Start-tag/End-tag (<tag></tag>) 和 Empty-element 标签 () 形式是语义等价.没有符合标准的 XML 解析器会区别对待它们.

No

Start-tag/End-tag (<tag></tag>) and Empty-element tag (<tag/>) forms are semantically equivalent. No conforming XML parser will treat them differently.

参考资料:可扩展标记语言 (XML) 1.0(第五版)

3.1 开始标签、结束标签和空-元素标签

空元素的标签

空元素标签可用于任何没有内容的元素,无论是否使用关键字 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.

1.2 术语

互操作性

[定义:标记一个描述非约束性建议的句子,以增加现有的 SGML 处理器可以处理 XML 文档的机会,这些处理器早于 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.]

相关问答:

XML 文件中的自闭合标签创建没有结束标记的 XML 元素XML 的根结束标记是强制​​性的吗?带结束标记和不带结束标记的 XML(自结束标记)什么是<tag/>在 XML 中是什么意思?

这篇关于&lt;tag/&gt; 之间是否存在语义差异?和&lt;tag&gt;&lt;/tag&gt;在 XML 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 10:41:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语义   是否存在   差异   lt   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!