XML schema 學習筆記

XML Schema

2008-10-26

XML schema

XML schema 用來描述XML文檔的類型,是對文檔更高層的抽象。

描述語言

XML Schema描述語言有:DTD, XML Schema等。

DTDXML規範所固有的,功能相對有限,除了用來描述schema,還可以有其它的用途。

什麼是 XML Schema?

XML schema語言之一,由W3C 發佈。



XML Schema 定義了XML文檔必須遵循的規則。這些規則通過 data model 來描述,包括:


  • the vocabulary (element and attribute names)

  • the content model (relationships and structure)

  • the data types.


XML Schema 的數據模型依賴於具體的data types。通過驗證的XML文檔將生成post-validation infoset,這使得XML文檔有了類型信息,從而可以將文檔當做對象看待,使用OOP技術來處理XML文檔。這對XML文檔處理軟件的開發非常有用。


驗證(Validation

檢查XML文檔是否遵循schema的過程,稱之爲驗證。

驗證有以下幾個級別:

  • The validation of the markup -- controlling the structure of a document.

  • The validation of the content of individual leaf nodes (datatyping)

  • The validation of integrity, i.e. of the links between nodes within a document or between documents.

  • Any other tests (often called "business rules").

目前schema對前兩種驗證支持的比較好,對link 驗證的支持很弱。


工具

XMLSpy

altova 公司出品;

使用XMLSpy創建schema的步驟:

  1. 創建Simple data type;

  2. 創建Complex data types;

  3. 創建elements, 及相關的Attributes;

  4. 創建elements 之間的關係,如:包含,順序,可選等;








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章