[
Lists Home |
Date Index |
Thread Index
]
Sorry,I post a wrong message. I forget to add a new namespace in the Second file. So I added it this time.but the question is the same. The parser said "it is invalid derived from restriction particle,base type:'{http://www.test.com/}Man,derived type:'{http://www.test.com/ok>}SuperMan'
When I use the whole document,it will not cause any problem.and everythings are OK
<xs:schema xmlns:dn="http://www.test.com/ " xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:simpleType name="PowerEnum”>
<xs:restriction base="xs:string">
<xs:enumeration value="1Pounds"/>
<xs:enumeration value="2Pounds"/>
<xs:enumeration value="300Pounds"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Man" abstract="true">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Power" type="PowerEnum"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="SuperMan">
<xs:complexContent>
<xs:restriction base="Man">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Power">
<xs:simpleType>
<xs:restriction base="PowerEnum">
<xs:enumeration value="1Pounds "/>
<xs:enumeration value="2Pounds "/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="OneMan" type="SuperMan"/>
<xs:element name="ok" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
but when I use the separate document,error occurred:parser(MS XML SDK)said I couldn’t use restriction to derive in main_derive.xsd
main.xsd
<xs:schema targetNamespace="http://www.test.com/" xmlns="http://www.test.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:simpleType name="PowerEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="1Pounds"/>
<xs:enumeration value="2Pounds"/>
<xs:enumeration value="300Pounds"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Man" abstract="true">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Power" type="PowerEnum"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
main_derive.xsd
<xs:schema xmlns="http://www.test.com/ok" targetNamespace="http://www.test.com/ok" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:im="http://www.test.com/" elementFormDefault="qualified">
<xs:import namespace="http://www.test.com/" schemaLocation="main.xsd"/>
<xs:complexType name="SuperMan">
<xs:complexContent>
<xs:restriction base="im:Man">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Power">
<xs:simpleType>
<xs:restriction base="im:PowerEnum">
<xs:enumeration value="300Pounds"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="OneMan" type="SuperMan"/>
<xs:element name="ok" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
sorry for consume all of ur time.
Best Regards
fbeyond
-----邮件原件-----
发件人: Henry S. Thompson [mailto:ht@cogsci.ed.ac.uk]
发送时间: 2003年4月30日 17:40
收件人: fc_方超
抄送: xml-dev@lists.xml.org
主题: Re: [xml-dev] import problem
=?utf-8?B?ZmNf5pa56LaF?= <fangc@bsoft.com.cn> writes:
> Hi,I got a namespace problem.
You're using import for a schema document with the same target
namespace as the importing document -- you should be using include.
See the W3C XML Schema Primer [1] for an example.
ht
[1] http://www.w3.org/TR/xmlschema-0/#SchemaInMultDocs
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
|