当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > 如何定制 XSD
XML documents can have a reference to a DTD or to an XML Schema.
XML文档可以与一份DTD或XML Schema相关联。
Look at this simple XML document called "note.xml":
请看下面一份名为"note.xml"的简易XML文档:
<?xml version="1.0"?> |
The following example is a DTD file called "note.dtd" that defines the elements of the XML document above ("note.xml"):
下述案例列举了名为"note.dtd"的DTD文件,它定义了上述XML文档("note.xml")中的元素:
<!ELEMENT note (to, from, heading, body)> |
The first line defines the note element to have four child elements: "to, from, heading, body".
第一行定义了包含“to、from、heading、body”四个子元素的“note”元素。
Line 2-5 defines the to, from, heading, body elements to be of type "#PCDATA".
第2到5行定义了"#PCDATA"类型的“to、from、heading、body”四个元素。
The following example is an XML Schema file called "note.xsd" that defines the elements of the XML document above ("note.xml"):
下述案例中,一个名为"note.xsd"的XML Schema文件定义了上述XML文档("note.xml")中的元素:
<?xml version="1.0"?> <xs:element name="note"> </xs:schema> |
The note element is a complex type because it contains other elements. The other elements (to, from, heading, body) are simple types because they do not contain other elements. You will learn more about simple and complex types in the following chapters.
Note元素是复合类型(complex type)因为它包含了其它元素;其它元素(to、rom、heading、 body)属于简单类型(simple type),因为它不包含其它元素。在下面的几章中,你会学习更多关于简单类型和复合类型的相关知识。
This XML document has a reference to a DTD:
下述这份XML文档与DTD相关:
<?xml version="1.0"?> <!DOCTYPE note SYSTEM <note> |
This XML document has a reference to an XML Schema:
下述这份XML文档与XML Schema相关:
<?xml version="1.0"?> <note |