title: "Elements ... does not resolve to a(n) type definition" in validation
body: <p>I am trying to create an XSD file to work as a filter to validate some XML files that will have to be processed further.</p>
  
  <p>Here is the XSL file: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;acknowledgement xmlns="http://sungardams.com/Validation.xsd" xmlns:common="http://sungardams.com/common.xsd"&gt;
      &lt;type&gt;POSITIVE&lt;/type&gt; &lt;!-- must have value POSITIVE --&gt;
      &lt;originReference&gt;
          &lt;externalMessageId&gt;12345678-010&lt;/externalMessageId&gt;
      &lt;/originReference&gt;
      &lt;requestMessageId&gt;000000000000000000000000001&lt;/requestMessageId&gt;
      &lt;senderInfo&gt;
          &lt;common:messageId&gt;000000000000000000000000000001&lt;/common:messageId&gt;
          &lt;common:externalMessageType&gt;securityAddRequest&lt;/common:externalMessageType&gt; &lt;!-- must have value securityAddRequest --&gt;
          &lt;common:applicationHistory&gt;
              &lt;common:originatorReference&gt;
                  &lt;common:originator&gt;GLOBAL PLUS&lt;/common:originator&gt; &lt;!-- must have value GLOBAL PLUS --&gt;
                  &lt;common:reference&gt;ABCDE001&lt;/common:reference&gt;
                  &lt;common:primaryReferenceType&gt;GREF&lt;/common:primaryReferenceType&gt; &lt;!-- must have value GREF --&gt;
              &lt;/common:originatorReference&gt;
          &lt;/common:applicationHistory&gt;
      &lt;/senderInfo&gt;
  &lt;/acknowledgement&gt;
  </code></pre>
  
  <p>The file I receive is validated using another XSD file, and uses the namespace <code>common</code> (to explain why some elements are prefixed <code>common:</code>).</p>
  
  <p>So I created the following XSD files:</p>
  
  <p>Validation.xsd</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:common="http://sungardams.com/common.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;xs:import namespace="http://sungardams.com/common.xsd" schemaLocation="http://sungardams.com/common.xsd antCommon001.xsd"/&gt;
  
      &lt;xs:element name="acknowledgement"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="type" type="xs:string" fixed="POSITIVE" /&gt;
                  &lt;xs:element name="originReference"&gt;
                      &lt;xs:complexType&gt;
                          &lt;xs:sequence&gt;
                              &lt;xs:element name="externalMessageId" type="xs:string" /&gt;
                          &lt;/xs:sequence&gt;
                      &lt;/xs:complexType&gt;
                  &lt;/xs:element&gt;
                  &lt;xs:element name="requestMessageId" type="xs:string" /&gt;
                  &lt;xs:element name="senderInfo" type="CType_SenderInfo_ant" /&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>At first, the element <code>senderInfo</code> was defined in this file. But when I tried it like that, I would get the error message that I the elements weren't valid (I would prefixe the name with the namespace <code>common:</code>, so would get the message that they were not valid xs:NCName).</p>
  
  <p>So I moved the sender info into another file: antCommon001.xsd</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
      &lt;xs:element name="CType_SenderInfo_ant"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="messageId" type="xs:string" /&gt;
                  &lt;xs:element name="externalMessageType" type="xs:string" fixed="securityAddRequest" /&gt;
                  &lt;xs:element name="applicationHistory"&gt;
                      &lt;xs:complexType&gt;
                          &lt;xs:sequence&gt;
                              &lt;xs:element name="originatorReference"&gt;
                                  &lt;xs:complexType&gt;
                                      &lt;xs:sequence&gt;
                                          &lt;xs:element name="originator" type="xs:string" fixed="GLOBAL PLUS" /&gt;
                                          &lt;xs:element name="reference" type="xs:string" /&gt;
                                          &lt;xs:element name="primaryReferenceType" type="xs:string" fixed="GREF" /&gt;
                                      &lt;/xs:sequence&gt;
                                  &lt;/xs:complexType&gt;
                              &lt;/xs:element&gt;
                          &lt;/xs:sequence&gt;
                      &lt;/xs:complexType&gt;
                  &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Now, when I run the validation of the XML file, I get the message (using Notepad++ XML Tools validation plugin):</p>
  
  <blockquote>
    <p>Unable to parse schema file ... element decl. 'senderInfo', attribute 'type': The QName value 'CType_SenderInfo_ant' does not resolve to a(n) type definition.</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>