I'm trying to make my own xml schema in Visual Studio. But I can't make any complex types such as a Rectangle type, nor inheritable types such as Shape. The schema.xsd follows and the errors I'm getting are :
Namespace '' is not available to be referenced in this schema. [line 6 xs:extension base="Shape">
Undefined complexType 'Shape' is used as a base for complex type extension [line 6 again ]
Content:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
attributeFormDefault="unqualified" 开发者_C百科
elementFormDefault="qualified"
xmlns:xs ="http://www.w3.org/2001/XMLSchema"
targetNamespace="MySchema">
<xs:complexType name="Rectangle">
<xs:complexContent>
<xs:extension base="Shape">
<xs:sequence>
<xs:element minOccurs="0" name ="X" type="xs:int"/>
<xs:element minOccurs="0" name ="Y" type="xs:int"/>
<xs:element minOccurs="0" name ="Width" type="xs:int"/>
<xs:element minOccurs="0" name ="Height" type="xs:int"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="Shape">
<xs:sequence>
<xs:element name="Complexity" type="xs:string"/>
</xs:sequence>
</xs:complexType>
You need to bind a prefix to the target namespace:
xmlns:m="MySchema"
and use this in references to components defined within the schema
base="m:Shape"
To resolve Namespace '' is not available to be referenced in this schema.
You can set the default ''
namespace without the need to change the rest of the file:
Add this xmlns="MySchema"
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs ="http://www.w3.org/2001/XMLSchema"
xmlns="MySchema"
targetNamespace="MySchema">
...
精彩评论