当前位置: 首页 > 网络学院 > XML相关教程 > DTD > DTD - XML 基本组件群
The main building blocks of both XML and HTML documents are elements.
XML和HTML的主要基本组件群就是元素。
Seen from a DTD point of view, all XML documents (and HTML documents) are made up by the following simple building blocks:
从DTD的角度来看,所有的XML文档(和HTML文档)都是由下述简单基本组件群构成的:
The following is a brief explanation of each of the building blocks:
下面是每个组件群的简短解释。
Elements are the main building blocks of both XML and HTML documents.
元素是XML文档和HTML文档的主要基本组件群。
Examples of HTML elements are "body" and "table". Examples of XML elements could be "note" and "message". Elements can contain text, other elements, or be empty. Examples of empty HTML elements are "hr", "br" and "img".
HTML元素的实例是"body" 和"table";XML元素的实例可以是"note" 和"message";元素可以包括文本、其它元素或空值。空值html元素的实例是"hr"、"br" 和 "img"。
Examples:
案例:
<body>body text in between</body> <message>some message in between</message> |
Attributes provide extra information about elements.
属性提供关于元素的特别信息。
Attributes are always placed inside the starting tag of an element. Attributes always come in name/value pairs. The following "img" element has additional information about a source file:
属性总是被放置在元素的起始标签内。属性一般是以“名称(name)/ 值(value)” 这样的成对形势出现的。下面的“img”元素就是关于源文件的补充信息:
<img src="computer.gif" /> |
The name of the element is "img". The name of the attribute is "src". The value of the attribute is "computer.gif". Since the element itself is empty it is closed by a " /".
该元素的名称是“img”,属性名称“src”,属性值是"computer.gif"。因为元素自身是空值,所以它是以“/” 结尾的。
Entities are variables used to define common text. Entity references are references to entities.
实体是用于定义普通文本的变量。实体参数是用于定义实体的参数。
Most of you will know the HTML entity reference: " ". This "no-breaking-space" entity is used in HTML to insert an extra space in a document. Entities are expanded when a document is parsed by an XML parser.
很多人都知道HTML的实体参数:" "。这里的"no-breaking-space"实体是在HTML中使用的,用于在文档中插入一个额外空间。当XML解析器解析一份文档时,实体就会得到扩展。
The following entities are predefined in XML:
下面的实体是在XML中预先定义的:
Entity References 实体参数 | Character 字符 |
---|---|
< | < |
> | > |
& | & |
" | " |
' | ' |
PCDATA means parsed character data.
PCDATA表示被解析的字符数据。
Think of character data as the text found between the start tag and the end tag of an XML element.
你可以把字符数据当作XML元素中起始标签与结束标签之间的文本内容。
PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded.
剖析器会解析PCDATA文本。文本中的标签会被当作标记,实体也将会得到扩展。
CDATA also means character data.
CDATA也是指字符数据。
CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.
解析器不会解析CDATA文本。文本中的标签不会被当作标记,实体也将不会得到扩展。