DTD。元素类型声明。 “ contentspec”和“ content model”之间的区别 [英] DTD. Element Type Declaration. Different between 'contentspec' and 'content model'

查看:144
本文介绍了DTD。元素类型声明。 “ contentspec”和“ content model”之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了可扩展标记语言(XML)1.0(第五版)W3C建议书11月26日2008


3.2元素类型声明具有:
元素类型声明采用以下形式:
元素类型声明

I read Extensible Markup Language (XML) 1.0 (Fifth Edition) W3C Recommendation 26 November 2008
3.2 Element Type Declarations has: An element type declaration takes the form: Element Type Declaration

elementdecl ::= <!ELEMENT Name contentspec >
contentspec ::= 'EMPTY' | 'ANY' | Mixed | children

3.2.1元素内容中具有:
元素内容模型

And in 3.2.1 Element Content has: Element-content Models

children ::= (choice | seq) ('?' | '*' | '+')?
cp ::= (Name | choice | seq) ('?' | '*' | '+')?
choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'
 seq ::=    '(' S? cp ( S? ',' S? cp )* S? ')'

在我提出疑问之后。

也许
contentspec 是ANY,PCDATA,Mixed,儿童

Maybe contentspec is ANY, PCDATA, Mixed, children.

,只有儿童具有 内容模型 :((elemName1 | elemName2,elemName3 ,elemET)。

And only children has 'content model': (elemName1 | elemName2, elemName3, elemET).

(名称|,'?''*''+'),顺序,选择-都是 内容模型。是吗?

(Name | , '?' '*' '+'), sequence, choice - all that is 'content model'. Right?

混合是否具有'内容模型'?

在教程中经常写:

<!ELEMENT Name content_model >


推荐答案

您明白了。


contentspec 是ANY,PCDATA,混合,子级。
只有孩子具有内容模型

contentspec is ANY, PCDATA, Mixed, children. And only children has 'content model'

它描述了元素可以具有的所有内容类型:

It describes all the types of content an element can have:


  • EMPTY 标签-没有内容

  • ANY DTD中定义的任何其他元素-一种自由格式

  • 混合内容,即XML建议3.1.2中的说明

  • 子项,在XML建议3.1.1中进行了描述

  • EMPTY tag -- no content
  • ANY any other elements defined in the DTD -- kind of free-form
  • Mixed content, which is decribed in 3.2.2 of the XML recommendation
  • children, which is described in 3.1.1 of the XML recommendation

内容模型允许使用序列,选择,父母等,例如(((a | b)|(c +,d ?, e *)))?,并且仅引用其他元素- #PCDATA

Content model allows to use sequence, choice, parenthis and so on, e.g. ((a|b)|(c+, d?, e*))?, and only reference others elements -- #PCDATA is not allowed here.

混合内容有点特殊,因为此模型只能使用选择,因此不同于内容模型。混合的内容是 #PCDATA (#PCDATA | a | b | c)* 之类的内容。在后一种情况下,您需要打开一个括号 #PCDATA 必须先出现,然后指定允许的元素由选择 | 分隔,并以零或更大的值关闭括号 >发生说明符 *

Mixed content is a bit particular since this model can only use choice, and therefore is distinct to content model. A mixed content is either #PCDATA or something like (#PCDATA | a | b | c)*. In the latter case you need to open an parenthesis (, #PCDATA must come first, then you specify the allowed elements separated by the choice | and finish by closing the parenthesis ), with the zero or more occurence specifier *.

所有这些结果的结果在 3.2.2混合内容

The consequence of all this is provided in 3.2.2 Mixed content :


在这种情况下,子元素的类型可能受到约束,但其顺序或出现次数不受约束

In this case, the types of the child elements may be constrained, but not their order or their number of occurrences

特别是,将无法定义元素:

In particular, it won't be possible to define an element:


  • 可以包含文本( #PCDATA )或元素序列:例如( #PCDATA )| (a,b,c))无效

  • 必须以一个元素开头,然后是文本,然后是其他元素:例如(a,#PCDATA ;, b,c)也无效

  • that can contain either text (#PCDATA) or a sequence of elements: e.g. (#PCDATA) | (a, b, c)) is not valid
  • that must start with an element, followed by text, then other element: e.g. (a, #PCDATA;, b, c) is also not valid

您也不能确保XML实例中的元素完全具有任何内容(可以保留为空)。

You can not also be ensured that your element in your XML instance will have any content at all (it can remain empty).

这篇关于DTD。元素类型声明。 “ contentspec”和“ content model”之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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