Some simple facts about XML (二)

下面的内容主要来自:

Practical XML Schema (A Java programmers guide to XML Schema and Namespaces)

http://www.javaworld.com/javaworld/jw-08-2005/jw-0808-xml.html?page=1#resources

 

 DTD & Schema

有两种方式定义XML的结构:Document Type Definition (DTD)  和 Schema。

 

DTD

   - DTDs were inherited from XML's origins as SGML (Standard Generalized Markup Language) and, as such, are limited in their expressiveness.

   - DTDs are for expressing a text document's structure, so all entities are assumed to be text.

   -  DTDs enforce a strict ordering of elements; schemas have a more flexible range of options (elements can be optional as a group, in any order, in strict sequence, etc.)

   - DTDs have their own syntax

 

XML Schema

   - The XML Schema language more closely resembles the way a database describes data。

   - Schemas provide the ability to define an element's type (string, integer, etc.) and much finer constraints (a positive integer, a string starting with an uppercase letter, etc.)

   - schemas are written in XML

 

 

XML 1.0 或 1.1

 XML exists in two versions: 1.0 defined in 1998 and 1.1 defined in 2004. XML 1.1 adds very little to 1.0: support for defining elements and attributes in languages such as Mongolian or Burmese, support for IBM mainframe end-of-line characters, and almost nothing else. For the vast majority of applications, these changes are not needed. Plus, a document declared as XML 1.1 will be rejected by a 1.0 parser. So stick with 1.0.

 

Well-formed and valid XML

well-formed就是文法正确,valid就是xml还要符合对应的DTD或Schema的定义(如果有的话)

 

 

 

你可能感兴趣的:(Some simple facts about XML (二))