曝光臺 注意防騙
網曝天貓店富美金盛家居專營店坑蒙拐騙欺詐消費者
把小于號寫成<可以出現在XML 和HTML 文本中。例如:
<CODE> for (int i =0;i <=args.length;i++){</CODE>
結構完整的XML 要求把&寫成&,把<寫成<,只要不是作為標記或者實體的一部分時都應如此。
#8:只能使用現有的5 個實體引用
讀者可能已經熟悉了幾個HTML 中的實體引用,例如©為插入版權號,® 為插入注冊商標號。但是除了已經討論過的
五個實體引用,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.使用的實體引用只有&、<、>、'和"。
校正這些問題并不難,只是有幾個稍不注意就會出現問題。下面讓我們仔細加以研究。
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.k6050.com
航空翻譯 www.aviation.cn
本文鏈接地址:
XML實用大全(46)