XSD 介紹

  XML結構定義 ( XML Schemas Definition )
  XML Schema 是DTD的替代品。XML Schema語言也就是XSD。
  XML Schema描述了XML文檔的結構。可以用一個指定的XML Schema來驗證某個XML文檔,以檢查該XML文檔是否符合其要求。文檔設計者可以通過XML Schema指定一個XML文檔所允許的結構和內容,並可據此檢查一個XML文檔是否是有效的。XML Schema本身是一個XML文檔,它符合XML語法結構。可以用通用的XML解析器解析它。
  一個XML Schema會定義:文檔中出現的元素、文檔中出現的屬性、子元素、子元素的數量、子元素的順序、元素是否爲空、元素和屬性的數據類型、元素或屬性的默認和固定值。
  XSD是DTD替代者的原因,一是據將來的條件可擴展,二是比DTD豐富和有用,三是用XML書寫,四是支持數據類型,五是支持命名空間。
  XSD文件的後綴名爲.xsd。
  XML Schema的優點:
  1) XML Schema基於XML,沒有專門的語法
  2) XML可以象其他XML文件一樣解析和處理
  3) XML Schema支持一系列的數據類型(int、float、Boolean、date等)
  4) XML Schema提供可擴充的數據模型。
  5) XML Schema支持綜合命名空間
  6) XML Schema支持屬性組。
  XML Schema is an XML-based alternative to DTD.
  An XML schema describes the structure of an XML document.
  The XML Schema language is also referred to as XML Schema Definition (XSD).
  The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD:
  ·defines elements that can appear in a document
  ·defines attributes that can appear in a document
  ·defines which elements are child elements
  ·defines the order of child elements
  ·defines the number of child elements
  ·defines whether an element is empty or can include text
  ·defines data types for elements and attributes
  ·defines default and fixed values for elements and attributes
  Very soon XML Schemas will be used in most Web applications as a replacement for DTDs:
  ·XML Schemas are extensible to future additions
  ·XML Schemas are richer and more powerful than DTDs
  ·XML Schemas are written in XML
  ·XML Schemas support data types
  ·XML Schemas support namespaces

 

附個人見解:

xml的Schema文件

如果把xml看做數據庫的數據,那麼Schema文件就相當於數據庫,表的結構(比如有哪些字段,約束等等)

 

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