+ -
当前位置:首页 → 问答吧 → 一个关于schema的问题 很着急 帮个忙

一个关于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>

作者: yangyumm   发布时间: 2011-05-10

XML文件改为:
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

热门下载

更多