schmintan

schmintan

  • NA
  • 64
  • 0

Type "namespace" is not declared, when importing namespace

Oct 17 2010 2:04 PM

Firstly, im vrey very new to xml and schemas, so apologies if this question is brutally basic.
I have created a schema, and am importing another schema that contains a complex type. I am getting the error "type http://myNamespace2.com/songSchema is not declared"
I have followed a number of tutorials and cant see where i have gone wrong. can anyone advise?

Here is the main schema. The second schema is the one i am importing. Thanks all.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XMLSchema1"
    targetNamespace="http://myNamespace1.com/XMLSchema1"
    elementFormDefault="qualified"
    xmlns="http://myNamespace1.com/XMLSchema1"
    xmlns:mstns="http://myNamespace1.com/XMLSchema1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:sn="http://myNamespace2.com/songSchema">
  <xs:import namespace="http://myNamespace2.com/songSchema" schemaLocation="C:\Development_Projects\XMLReaderWriter\XMLReaderWriter\XMLReaderWriter\songSchema.xsd"/>

  <xs:element name="Record">
    
    <xs:complexType>
      
      <xs:sequence>
        <xs:element name="RecordType" type="xs:string"/>
        <xs:element name="Artist" type ="xs:string"/>
        <xs:element name="NumSongs" type ="xs:int"/>
        <xs:element name="SongDetails" type="sn:Song"/> <!--ERROR OCCURS HERE-->
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
 
 <!-- 2nd scheema that i am importing-->

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="songSchema"
targetNamespace="http://myNamespace2.com/songSchema"
elementFormDefault="qualified"
xmlns="http://myNamespace2.com/songSchema"
xmlns:mstns="http://myNamespace2.com/songSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="Song">
<xs:complexType>
<xs:sequence>
<xs:element name="SongName" type="xs:string"/>
<xs:element name="Length" type="xs:string"/>
<xs:element name="Genre" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Answers (2)