加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

可以在XML声明之前发表评论吗?

发布时间:2020-12-16 08:05:13 所属栏目:百科 来源:网络整理
导读:将XML声明之前的注释放在XML文件中可以吗? !--Is this bad to do?--?xml version="1.0" encoding="utf-8"?someElement / 不,不行 Appendix F of the XML spec说: Because each XML entity not accompanied by external encoding information and not in U
将XML声明之前的注释放在XML文件中可以吗?
<!--
Is this bad to do?
-->
<?xml version="1.0" encoding="utf-8"?>
<someElement />
不,不行

Appendix F of the XML spec说:

Because each XML entity not
accompanied by external encoding
information and not in UTF-8 or UTF-16
encoding must begin with an XML
encoding declaration,in which the
first characters must be ‘< ?xml’,any
conforming processor can detect,after
two to four octets of input,which of
the following cases apply.

啊,但是,F节是非规范的,你说。

那么,section 2.1给出了一个格式良好的XML文档的生产,因此:

[1]     document       ::=       prolog element Misc*

…在section 2.8我们得到了“prolog”的生产:

[22]    prolog     ::=       XMLDecl? Misc* (doctypedecl Misc*)?
[23]    XMLDecl    ::=      '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'

所以,你可以省略< ?xml声明,但你不能用任何东西前缀。 (顺便提及,“杂项”是评论的类别)。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读