XML 文档对 DTD 或 XML Schema 进行引用
2013-08-23 13:53
316 查看
(本文摘自w3school)
一个简单的 XML 文档:
请看这个名为 "note.xml" 的 XML 文档:<?xml version="1.0"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
DTD 文件
下面这个例子是名为 "note.dtd" 的 DTD 文件,它对上面那个 XML 文档的元素进行了定义:<!ELEMENT note (to, from, heading, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>
第 1 行定义 note 元素有四个子元素:"to, from, heading, body"。
第 2-5 行定义了 to, from, heading, body 元素的类型是 "#PCDATA"。
XML Schema
下面这个例子是一个名为 "note.xsd" 的 XML Schema 文件,它定义了上面那个 XML 文档的元素:<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3school.com.cn" xmlns="http://www.w3school.com.cn" elementFormDefault="qualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
note 元素是一个复合类型,因为它包含其他的子元素。其他元素 (to, from, heading, body) 是简易类型,因为它们没有包含其他元素。您将在下面的章节学习更多有关复合类型和简易类型的知识。
对 DTD 的引用
此文件包含对 DTD 的引用:<?xml version="1.0"?> DE><!DOCTYPE note SYSTEM "http://www.w3school.com.cn/dtd/note.dtd">DE> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
对 XML Schema 的引用
此文件包含对 XML Schema 的引用:<?xml version="1.0"?> <note xmlns="http://www.w3school.com.cn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" DE>xsi:schemaLocation="http://www.w3school.com.cn note.xsd"DE>> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
相关文章推荐
- XML 文档可对 DTD 或 XML Schema 进行引用
- XML 文档对 DTD 或 XML Schema 进行引用
- 为Eclipse添加XML文档所使用的DTD或XML Schema
- 从Xml文档内部引用Xml Schema验证
- 为Eclipse添加XML文档所使用的DTD或XML Schema(xml编辑提示)
- 使用DTD文档对 xml 1 作业中的xml文档进行约束,其中河北省只能依次包含石家庄市、张家口市、保定市这三个市,保定市可以有多个或者1个,给保定市定义属性编号为ID类型,必须有;属性name为字符
- XML文档类型定义---XML Schema
- 带DTD 的XML 用SAX进行解析
- Oracle 远程访问配置 在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标 C#反序列化XML异常:在 XML文档(0, 0)中有一个错误“缺少根元素” C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper Decimal类型截取保留N位小数向上取, Decimal类型截取保留N位小数并且不进行四舍五入操作
- 使用JAXP对XML文档进行DOM解析
- 使用CSS对XML文档进行格式化
- 【XML开发】(1)通过"文档类型定义(DTD)"来定义XML标记语言
- 使用Javascript和PHP对服务端XML文档进行操作
- XML--- XML文档类型定义(DTD)
- xml schema与xml dtd文件相比较的优点
- XML Schema 与 XML DTD的技术比较与分析
- Java对XML文档进行解析
- Java对XML文档进行解析(SAX、StAX解析)
- java 使用DOM对XML文档进行增删改查操作
- 我用vs2005写了一个webservice用来查询sql2005数据库中表值,返回一个dataset类型集合,测试时候显示的xml文档没有问题,但是当我添加web引用的时候却无法正常显示而且报错原因之一。