以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  xml schema错误--新人提问。  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=50962)


--  作者:chengdihan
--  发布时间:8/4/2007 2:01:00 PM

--  xml schema错误--新人提问。
用xmlspy编译以下schema的时候出错:personinfo must refer to an existing simple or complex type. 什么原因呢?请指教。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.tedcheng.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:element name="person" type="personinfo"/>

<xs:complexType  name="personinfo">
   <xs:sequence>
   <xs:element name="lastname" type="xs:string"/>
   <xs:element name="age" type="xs:string"/>
   <xs:element name="dateborn" type="xs:string"/>      
   </xs:sequence>
</xs:complexType>

</xs:schema>


--  作者:taha
--  发布时间:8/9/2007 11:46:00 PM

--  
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.tedcheng.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:element name="person" >
  <xs:complexType >

改成这样应该没问题了吧?
   <xs:sequence>
   <xs:element ref="personinfo" />
   </xs:sequence>
</xs:complexType>
</xs:element>
  <xs:element name="personinfo" >
  <xs:complexType >
   <xs:sequence>
   <xs:element name="lastname" type="xs:string"/>
   <xs:element name="age" type="xs:string"/>
   <xs:element name="dateborn" type="xs:string"/>
    </xs:sequence>
</xs:complexType >

</xs:schema>


--  作者:taha
--  发布时间:8/9/2007 11:49:00 PM

--  
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.tedcheng.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:element name="person" >
  <xs:complexType >
   <xs:sequence>
   <xs:element ref="personinfo" />
   </xs:sequence>
  </xs:complexType>
</xs:element>
<xs:element name="personinfo" >
  <xs:complexType >
   <xs:sequence>
   <xs:element name="lastname" type="xs:string"/>
   <xs:element name="age" type="xs:string"/>
   <xs:element name="dateborn" type="xs:string"/>
   </xs:sequence>
  </xs:complexType >
</xs:element>
</xs:schema>
应该是这样.
--  作者:yande1865
--  发布时间:8/11/2007 9:09:00 PM

--  
其实房主你写的我已经在C#测试过了,没有错!!因为你是在元素里面引用复杂类型!这是对的!但为什么在xmlspy有错!这个确实是问题!
--  作者:Az2lis
--  发布时间:8/21/2007 1:34:00 AM

--  
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsdLocal="http://www.tedcheng.com"
targetNamespace="http://www.tedcheng.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:element name="person" type="xsdLocal:personinfo"/>

<xs:complexType  name="personinfo">
   <xs:sequence>
   <xs:element name="lastname" type="xs:string"/>
   <xs:element name="age" type="xs:string"/>
   <xs:element name="dateborn" type="xs:string"/>      
   </xs:sequence>
</xs:complexType>

</xs:schema>
--  作者:Az2lis
--  发布时间:8/21/2007 1:35:00 AM

--  
加上个 xmlns:xsdLocal="http://www.tedcheng.com",然后引用的地方 type="xsdLocal:personinfo",这样应该可以验证过了,试试吧
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms