HTML / SGML / XML / DTD声明中的注释 [英] Comments inside HTML/SGML/XML/DTD declarations

查看:169
本文介绍了HTML / SGML / XML / DTD声明中的注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

W3C HTML中4.01 DTD 和更早版本的内联注释在声明中经常使用。

In the W3C HTML 4.01 DTDs and earlier, inline comments are frequently used within declarations.

例如, HTML 2.0严格DTD 具有:

<!ENTITY % HTML.Version
    "-//IETF//DTD HTML 2.0 Strict//EN"

        -- Typical usage:

            <!DOCTYPE HTML PUBLIC
        "-//IETF//DTD HTML Strict//EN">
        <html>
        ...
        </html>
    --
    >

其中 HTML 实体声明包含注释在两个双连字符-之间。

where the HTML entity declaration contains a comment between two double hyphens --.

但是,DTD验证程序似乎完全拒绝这些内部注释,并且

However, DTD validators seem to flat out reject these sorts of internal comments and throw an error.

验证器是否错误,或者W3C DTD格式不正确?

Are the validators wrong, or are the W3C DTDs not well-formed?

在进一步研究中,这似乎是由于 SGML XML 规范。

In looking into it further, it seems that this is due to differences between the SGML and XML specifications.

本质上,SGML将注释定义为开头和结尾-开头声明构造< ;! > ,而XML要求注释开始并结束分别使用<!--> 分隔符作为独立的构造。

Essentially, SGML defines comments as beginning and ending with -- anywhere inside a declaration construct <! >, whereas XML requires comments to begin and end with the <!-- and --> delimiters, respectively, as independent constructs.

由于4.01版之前的HTML基于SGML,因此声明内的注释是允许的,并由官方DTD使用。

Because HTML up to version 4.01 was based on SGML, comments within declarations were allowed and were used by the official DTDs.

但是,大多数DTD验证器似乎仅检查是否符合更简单的XML规范,因此,会因声明内的注释和错误输入而感到困惑。

However, most DTD validators seem to only check for compliance with the simpler XML specification and, therefore, get confused by intra-declaration comments, barfing errors.

推荐答案

在进一步研究中,这似乎是由于SGML和XML规范之间的差异所致。

In looking into it further, it seems that this is due to differences between the SGML and XML specifications.

本质上,SGML定义了注释以开头和结尾以-声明构造,而XML需要对作为分隔符分别以开始和结束。

Essentially, SGML defines comments as beginning and ending with -- anywhere inside a declaration construct , whereas XML requires comments to begin and end with the delimiters, respectively, as independent constructs.

因为直到4.01版的HTML都是基于SGML,声明中允许使用注释,并且由官方DTD使用。

Because HTML up to version 4.01 was based on SGML, comments within declarations were allowed and were used by the official DTDs.

但是,大多数DTD验证程序似乎仅检查是否符合更简单的XML规范,因此会因声明中的注释和错误输入而感到困惑。

However, most DTD validators seem to only check for compliance with the simpler XML specification and, therefore, get confused by intra-declaration comments, barfing errors.

这篇关于HTML / SGML / XML / DTD声明中的注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆