I have an XML file and two XSD files. Both XSD files are well-formed and validate. The XML file is well formed, but when I try to validate it, it says "Error at line 25, clumn 46: type 'http://www.w3.org/2001/XMLSchema:topicType' not found. Is that an error with the import statement? Is something wrong with my code for the imported XSD file where I declare topicType? Something wrong with the XML file? Any help will be greatly appreciated as I can't seem to fix the error.
XML File:
<?xml version="1.0" encoding="UTF-8"?>
<presentations
xmlns="http://www.example.com/contacts"
xmlns:name="http://www.example.com/name"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/contacts main.xsd"
source="Beginning XML 5E"
version="1.0">
<presentation date="2013-07-31" length="PT30M">
<topic genre="Music">PianoML</topic>
<presenters>
<name title="Mr." id="Y258">
<first>Elvis</first>
<middle>A</middle>
<last>Presley </last>
</name>
<name title="Miss" id="X365">
<first>Lady</first>
<last>Gaga</last>
</name>
</presenters>
</presentation>
<presentation date="2013-08-05" length="PT35M">
<topic genre="Science">AlienML</topic>
<presenters>
<name title="Mr." id="Y007">
<first>Will</first>
<last>Smith</last>
</name>
<name title="Mr." id="Y360">
<first>Tommy</first>
<first>Lee</first>
<last>Jones</last>
</name>
</presenters>
</presentation>
</presentations>
Main XSD File:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:contacts="http://www.example.com/contacts"
xmlns:name="http://www.example.com/name"
targetNamespace="http://www.example.com/contacts"
elementFormDefault="qualified">
<import namespace="http://www.example.com/name" schemaLocation="topic.xsd" />
<!-- Presentations Element -->
<complexType name="presentationsType">
<sequence minOccurs="0" maxOccurs="unbounded">
<element ref="presentation"/>
</sequence>
</complexType>
<!-- Presentation Element -->
<complexType name="presentationType">
<sequence>
<element ref="topic"/>
<element ref="presenters"/>
</sequence>
<!-- Attribute group reference for presentation Element -->
<attributeGroup ref="presentationAttr" />
</complexType>
<!-- Presenters Element -->
<complexType name="presentersType">
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="name"/>
</sequence>
</complexType>
<!-- Name Element -->
<complexType name="nameType">
<!-- Element group reference for name Group -->
<group ref="nameGroup" />
<!-- Attribute group reference for name Element -->
<attributeGroup ref="nameAttr" />
</complexType>
<!-- Element declarations -->
<element name="presentations" type="presentationsType" />
<element name="presentation" type="presentationType" />
<element name="presenters" type="presentersType" />
<element name="name" type="nameType" />
<element name="first" type="string"/>
<element name="middle" type="string"/>
<element name="last" type="string"/>
<!--Element group definition for name Element -->
<group name="nameGroup">
<sequence>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="first"/>
</sequence>
<sequence minOccurs="0" maxOccurs="1">
<element ref="middle"/>
</sequence>
<element ref="last"/>
</sequence>
</group>
<!-- Attribute group definition for presentation Element -->
<attributeGroup name="presentationAttr">
<attribute name="date" type="date" use="required"/>
<attribute name="length" type="duration" use="required"/>
</attributeGroup>
<!-- Attribute group definition for name Element -->
<attributeGroup name="nameAttr">
<!-- ID must begin with either X or Y and be followed by 3 digits -->
<attribute name="id" use="required">
<simpleType>
<restriction base="ID">
<pattern value="[X|Y][0-9]{3}" />
</restriction>
</simpleType>
</attribute>
<!-- Title attribute must be either Mr., Mrs., Ms., or Miss -->
<attribute name="title" use="required">
<simpleType>
<restriction base="string">
<enumeration value="Mr."/>
<enumeration value="Mrs."/>
<enumeration value="Ms."/>
<enumeration value="Miss"/>
</restriction>
</simpleType>
</attribute>
</attributeGroup>
</schema>
Imported XSD File:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:target="http://www.example.com/name"
targetNamespace="http://www.example.com/name"
elementFormDefault="qualified">
<!-- Topic Element -->
<complexType name="topicType">
<simpleContent>
<extension base="string">
<attribute name="genre" use="required">
<simpleType>
<restriction base="string">
<enumeration value="ART" />
<enumeration value="Music" />
<enumeration value="Science" />
<enumeration value="Technology" />
</restriction>
</simpleType>
</attribute>
</extension>
</simpleContent>
</complexType>
<element name="topic" type="topicType" />
</schema>