DTD - XML 建立 blocks

The main building blocks of both XML and HTML documents are tags like <body>....</body>.
像<body>....</body>之类的标签是XML和HTML文件的主组件群。


The building blocks of XML documents
XML文件的组件群

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文件)都是由接下来的简单组件群组成的:

  • Elements
    元素
  • Attributes
    属性
  • Entities
    实体
  • PCDATA
    被解析的字符数据(Parsed Character Data)
  • CDATA
    字符数据值(Character Data)

The following is a brief explanation of each of the building blocks:
下面是每个组件群的简短解释。


Elements
元素

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
属性

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
实体

Entities are variables used to define common text. Entity references are references to entities.
实体是对于定义普通文件的变量。实体参数是定义实体的参数。

Most of you will know the HTML entity reference: "&nbsp;". 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实体参数:"&nbsp;"。这里的"no-breaking-space"实体是在HTML中用来在文本中插入一个额外空间的。当XML剖析器解析文件时,实体就会得到扩展。

The following entities are predefined in XML:
下面的实体是在XML中预定的:

Entity References
实体参数
Character
字符
&lt;<
&gt;>
&amp;&
&quot;"
&apos;'
 

PCDATA

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

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文本。文本中的标签不会作为标示字体,实体也将不会得到扩展。

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值