8,906
社区成员
发帖
与我相关
我的任务
分享
Schema文件和XML文件需要做如下修改.需要用带XML有效性验证的程序验证.
book.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.ricky.com/book" targetNamespace="http://www.ricky.com/book" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="books">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="book" type="bookType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="bookType">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="atitle" type="xs:string" minOccurs="0"/>
<xs:element name="apublisher" type="xs:string" minOccurs="0"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="translator" type="xs:string"/>
<xs:element name="publisher" type="xs:string"/>
<xs:element name="publishDate" type="xs:string"/>
<xs:element name="bookId" type="xs:string"/>
<xs:element name="pages" type="xs:string"/>
<xs:element name="publishNumber" type="xs:string"/>
</xs:sequence>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Foreign"/>
<xs:enumeration value="Chinese"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:schema>
books.xml
<?xml version="1.0" encoding="GB2312" standalone="yes"?>
<books
xmlns="http://www.ricky.com/book"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ricky.com/book book.xsd">
<book type="Foreign">
<title>SQL Server 2005 从入门到精通(应用技术基础)</title>
<atitle>Microsoft SQL Server 2005 Applied Techniques Step by Step</atitle>
<apublisher>Microsoft Press</apublisher>
<author>(美)Solid Quality Learning</author>
<translator>王为</translator>
<publisher>清华大学出版社</publisher>
<publishDate>2006-9-1</publishDate>
<bookId>7-302-13801</bookId>
<pages>280</pages>
<publishNumber>1-1</publishNumber>
</book>
<book type="Chinese">
<title>数据恢复技术</title>
<author>戴士剑,涂彦辉</author>
<translator>王为</translator>
<publisher>电子工业出版社</publisher>
<publishDate>2005-3-1</publishDate>
<bookId>7-121-00756-8</bookId>
<pages>711</pages>
<publishNumber>2-1</publishNumber>
</book>
</books>