以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML工具及XML开发环境 』  (http://bbs.xml.org.cn/list.asp?boardid=7)
----  请教!!!!!XMLSpy的一个问题!!!!!!!!  (http://bbs.xml.org.cn/dispbbs.asp?boardid=7&rootid=&id=47483)


--  作者:Adair_CLO
--  发布时间:5/24/2007 4:18:00 PM

--  请教!!!!!XMLSpy的一个问题!!!!!!!!
我用的是XMLSpy 2005 Enterprise Edition...
新建了个xml schema文件:shirt.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.try.com" targetNamespace="http://www.try.com">
<xsd:element name="shirt">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="color" type="xsd:string" minOccurs="0"/>
            <xsd:element name="size" type="xsd:int" minOccurs="0"/>
       </xsd:sequence>
   </xsd:complexType>
</xsd:element>
</xsd:schema>
通过了xmlspy的检验,是无错。。
于是我就建了一个参照shirt.xsd的xml文件:shirt.xml
内容如下:
<?xml version="1.0" encoding="utf-8"?>
<shirt xmlns="http://www.try.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.try.com shirt.xsd">
    <color>abc</color>
    <size>123</size>
</shirt>
可是,这时xmlspy检验出错了!!出错信息:
This file is no valid:
Unexpected element 'color' in element 'shirt' . Expected: color, size
为什么会这样,明明没错的。。。。这个出错信息不是自相矛盾吗??又不让有color,有希望是color。。。
另外,当我将shirt.xml中的<color>abc</color><size>123</size>删去,xmlspy就没有报错。。。。。那就说明xml文档与schema文件没有关联错吧。。。

到底是因为什么呢?????????????????????????


--  作者:zxpzxpzxp
--  发布时间:7/16/2007 4:40:00 PM

--  
It's wrong to set minOccurs to 0, and there is no maxOccurs. In this situation, the default value of maxOccurs is 0. It means you set minOccurs and maxOccurs 0.
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms