<tag/> 之间是否存在语义差异?和<tag></tag>在 XML 中? [英] Is there a semantic difference between <tag /> and <tag></tag> in XML?

查看:33
本文介绍了<tag/> 之间是否存在语义差异?和<tag></tag>在 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?

推荐答案

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(第五版)

空元素标签可用于任何没有内容的元素,无论是否使用关键字 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秒登录
发送“验证码”获取 | 15天全站免登陆