什么是“-O”?声明 DTD 元素类型时的含义是什么?

发布于 2024-12-13 09:24:58 字数 722 浏览 4 评论 0原文

根据 W3C XML 规范,元素以 form 的形式声明:

[45]    elementdecl    ::=      '<!ELEMENT' S Name S contentspec S? '>'
[46]    contentspec    ::=      'EMPTY' | 'ANY' | Mixed | children

w3school 上的示例是:

 <!ELEMENT br EMPTY>

但是在html 4.01 strict dtd元素br是:

<!ELEMENT BR - O EMPTY                 -- forced line break -->

为什么第二个声明要加“ - O”?这意味着什么?我在哪里可以找到这方面的官方文档?

According W3C XML specification, element is declared in form of :

[45]    elementdecl    ::=      '<!ELEMENT' S Name S contentspec S? '>'
[46]    contentspec    ::=      'EMPTY' | 'ANY' | Mixed | children

And samples on w3school is :

 <!ELEMENT br EMPTY>

But in html 4.01 strict dtd element br is :

<!ELEMENT BR - O EMPTY                 -- forced line break -->

Why the second declaration add “- O”? What it means? And Where can I find the offical document about this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉怎暖 2024-12-20 09:24:58

连字符表示必需,O 表示可选。所以“-O”表示开始标签是必需的,结束标签是可选的。您可以在 §3.3.3 中阅读更多内容

The hyphen means required, the O means optional. So "- O" means that the opening tag is required, and the closing tag is optional. You can read more in §3.3.3

能否归途做我良人 2024-12-20 09:24:58

就像@erickson所说,连字符表示“必需”,“O”表示可选。第一个 -/O 用于开始标记,第二个 -/O 用于结束标记。这称为标签最小化。

标记最小化仅在 SGML DTD 中允许。这就是为什么您在 HTML 严格 DTD 中看到它,但在 XML 规范或 XML 示例中看不到它的原因在 w3schools 上。

Like @erickson said, the hyphen means "required" and "O" means optional. The first -/O is for the start tag and the second -/O is for the end tag. This is called tag minimization.

Tag minimization is only allowed in SGML DTDs. This is why you see it in the HTML Strict DTD, but you don't see it in the XML Spec or the XML examples on w3schools.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文