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

查看:31
本文介绍了<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?

推荐答案

开始标签/结束标签(<tag></tag>)和空元素标签()形式是语义等价.没有符合标准的 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天全站免登陆