一个关于schema的问题 很着急 帮个忙
时间:2011-05-10
来源:互联网
以下是两个文件 老出错怎么回事 各位帮帮忙,很着急!
<?xml version="1.0" encoding="gb2312"?>
<booklist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="li4-1.xsd">
<book isbn="7-04-008653">
<name>数据通信与计算机网络</name>
<author>王震江</author>
<press>高等教育出版社</press>
<pubdate>2000.7</pubdate>
<price>23.9</price>
</book>
<book isbn="7-113-05310-6/tp.956">
<name>操作系统</name>
<author>薛智文</author>
<press>中国铁道出版社</press>
<pubdate>2003.6</pubdate>
<price>32.00</price>
</book>
</booklist>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="booklist">
<xs:complexType>
<xs:element name="book" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="press" type="xs:string"/>
<xs:element name="pubdate" type="xs:dateTime"/>
<xs:element name="price">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="7"/>
<xs:fractionDigits value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="isbn" type="xs:ID"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="gb2312"?>
<booklist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="li4-1.xsd">
<book isbn="7-04-008653">
<name>数据通信与计算机网络</name>
<author>王震江</author>
<press>高等教育出版社</press>
<pubdate>2000.7</pubdate>
<price>23.9</price>
</book>
<book isbn="7-113-05310-6/tp.956">
<name>操作系统</name>
<author>薛智文</author>
<press>中国铁道出版社</press>
<pubdate>2003.6</pubdate>
<price>32.00</price>
</book>
</booklist>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="booklist">
<xs:complexType>
<xs:element name="book" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="press" type="xs:string"/>
<xs:element name="pubdate" type="xs:dateTime"/>
<xs:element name="price">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="7"/>
<xs:fractionDigits value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="isbn" type="xs:ID"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:schema>
作者: yangyumm 发布时间: 2011-05-10
XML文件改为:
XML code
li4-1.xsd文件改为:
XML code
错误挺多的,主要有:
(1)xsd文件中xs:complexType后面不能将xs:element作为子节点
(2)pubdate里的数据不是dateTime型的,应改成string类型;如果想改成dateTime类型,请看我修改的XML文件;
(3)isbn如果是ID类型的,则isbn的取值中,不能以数字开头,且不能有“/”,请按我修改的XML文件修改;否则请将xsd文件的isbn改成string类型的。
XML code
<?xml version="1.0" encoding="gb2312"?> <booklist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="li4-1.xsd"> <book isbn="_7-04-008653"> <name>数据通信与计算机网络</name> <author>王震江</author> <press>高等教育出版社</press> <pubdate>2000-07-01T00:00:00</pubdate> <price>23.9</price> </book> <book isbn="_7-113-05310-6_tp.956"> <name>操作系统</name> <author>薛智文</author> <press>中国铁道出版社</press> <pubdate>2003-06-01T00:00:00</pubdate> <price>32.00</price> </book> </booklist>
li4-1.xsd文件改为:
XML code
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="booklist"> <xs:complexType> <xs:sequence> <xs:element name="book" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="author" type="xs:string"/> <xs:element name="press" type="xs:string"/> <xs:element name="pubdate" type="xs:dateTime"/> <xs:element name="price"> <xs:simpleType> <xs:restriction base="xs:decimal"> <xs:totalDigits value="7"/> <xs:fractionDigits value="2"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> <xs:attribute name="isbn" type="xs:ID"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
错误挺多的,主要有:
(1)xsd文件中xs:complexType后面不能将xs:element作为子节点
(2)pubdate里的数据不是dateTime型的,应改成string类型;如果想改成dateTime类型,请看我修改的XML文件;
(3)isbn如果是ID类型的,则isbn的取值中,不能以数字开头,且不能有“/”,请按我修改的XML文件修改;否则请将xsd文件的isbn改成string类型的。
作者: zhangchaokun 发布时间: 2011-05-13
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28