• 热门标签

当前位置: 主页 > 航空资料 > 计算机 >

时间:2010-08-09 13:24来源:蓝天飞行翻译 作者:admin
曝光台 注意防骗 网曝天猫店富美金盛家居专营店坑蒙拐骗欺诈消费者

把小于号写成<可以出现在XML 和HTML 文本中。例如:
<CODE> for (int i =0;i &lt;=args.length;i++){</CODE>
结构完整的XML 要求把&写成&amp;,把<写成&lt;,只要不是作为标记或者实体的一部分时都应如此。
#8:只能使用现有的5 个实体引用
读者可能已经熟悉了几个HTML 中的实体引用,例如&copy;为插入版权号,&reg 为插入注册商标号。但是除了已经讨论过的
五个实体引用,XML 只能使用预先在DTD 中定义过的实体引用。
XML 实用大全
第 145 页
但是现在读者可能还不了解DTD,如果与字符&出现在文档中的任何地方,其后必须紧跟amp;、lt;、gt;、apos;或者quot;。
所有其他的用法均会破坏结构完整性。
在第9 章“实体和外部DTD 子集”中将会学习如何使用DTD 定义插入特殊符号和大块样板文本的新实体引用。
XML 实用大全
第 146 页
6.4 结构完整的HTML
即使在大部分Web 浏览器还不能直接支持XML 的情况下,也可以通过编写结构完整的HTML 来练习XML 技巧。这就是遵守XML
的结构完整性约束,但只是使用标准的HTML 标记的HTML。结构完整的HTML 比多数人和FrontPage 等工具编写的不标准的
HTML 容易读取,同时容易被Web 机器人中用动检索引擎理解。它更为强健,对它作一些改动不会破坏它,在转移的过程中
不会因为变换浏览器和操作平台对它产生影响。而且可以使用XML 工具服务于HTML 文档,这对于那些服务器不支持XML 的
读者来说仍然保持了向后的兼容性。
6.4.1 现实的Web 页面存在的问题
真正的Web 页面非常不标准。没有结束标记,元素重叠,在页面中包含未经处理的小于号,忽略实体引用后面的分号。存在
这些问题的Web 页面严格来讲是无效的,但部分浏览器能接受它们。不过如果校正了这些问题,页面将会更整洁,显示更快,
更容易维护。
Web 页面包含的一些常见的问题:
1. 起始标记没有对应的结束标记(没有结束元素)
2. 结束标记没有相应的起始标记
3. 元素重叠
4. 属性值未加引号
5. 没有避免使用<、>、&和"符号
6. 没有根元素
7. 结束标记与起始标记不匹配
清单大致按照其重要性排列,但确切的细节因标记不同而变化。例如,没有被结束的<STRONG>标记会把跟随其后的所有元素
变为粗体。但是没有被结束的<LI>或者<P>标记不会引发任何问题。
有几条规则仅适用于XML 文档,如果试图把它们汇集在已存在的HTML 页面中,确实会带来问题。这些规则有:
1.以一个XML 声明开始
2.空标记必须以/>结束
3.使用的实体引用只有&amp;、&lt;、&gt;、&apos;和&quot;。
校正这些问题并不难,只是有几个稍不注意就会出现问题。下面让我们仔细加以研究。
6.4.1.1 结束所有的起始标记
任何含有内容的元素,无论是文本还是别的子元素,应该有一个起始标记和结束标记。HTML 不绝对要求这样做。例如<P>、
<DT>、<DD>和<LI>经常被单独使用。但是,这样做主要依靠Web 浏览器能够很好地判断一个元素的结束位置,浏览器并不总
能确切地按照作者的意愿去做。因此最好是明确地结束所有起始标记。
对于编写HTML 的方法,这里要求对其所作的最大改变是把<P>看作一个容器,而不是一个简单的段落分界符。例如,以前格
式化Federalist Papers 的开始部分,如下所示:
To the People of the State of New York:
XML 实用大全
第 147 页
<P>
AFTER an unequivocal experience of the inefficiency of the
subsisting federal government,you are called upon to
deliberate on a new Constitution for the United States of
America.The subject speaks its own importance;comprehending
in its consequences nothing less than the existence of the
UNION,the safety and welfare of the parts of which it is
composed,the fate of an empire in many respects the most
interesting in the world.It has been frequently remarked that
it seems to have been reserved to the people of this country,
by their conduct and example,to decide the important question,
whether societies of men are really capable or not of
establishing good government from reflection and choice,or
whether they are forever destined to depend for their political
constitutions on accident and force.If there be any truth in
the remark,the crisis at which we are arrived may with
propriety be regarded as the era in which that decision is to
be made;and a wrong election of the part we shall act may,in
this view,deserve to be considered as the general misfortune
of mankind.
<P>
结构完整性要求将上面语句格式化为:
<P>
To the People of the State of New York:
XML 实用大全
第 148 页
</P>
<P>
AFTER an unequivocal experience of the inefficiency of the
subsisting federal government,you are called upon to
deliberate on a new Constitution for the United States of
America.The subject speaks its own importance;comprehending
in its consequences nothing less than the existence of the
UNION,the safety and welfare of the parts of which it is
composed,the fate of an empire in many respects the most
interesting in the world.It has been frequently remarked that
it seems to have been reserved to the people of this country,
by their conduct and example,to decide the important question,
 
中国航空网 www.aero.cn
航空翻译 www.aviation.cn
本文链接地址:XML实用大全(46)