title: Specify namespace for an element in XSD
body: <p>I've got an XML for which I need to generate an XSD. My XML goes as follows:</p>
  
  <p><strong>Instance:</strong></p>
  
  <pre><code>    &lt;mes:GetInboundResponseGetInboundSMS 
            xmlns:mes="http://abcd.com"&gt;
           &lt;response&gt;
              &lt;messages&gt;
                 &lt;item&gt;
                    &lt;date&gt;15/04/2014 00:00:00&lt;/date&gt;
                 &lt;/item&gt;
                 &lt;item&gt;
                    &lt;date&gt;01/07/2014 10:01:32&lt;/date&gt;
                 &lt;/item&gt;
              &lt;/messages&gt;
           &lt;/response&gt;
      &lt;/mes:GetInboundResponseGetInboundSMS&gt;
  </code></pre>
  
  <p>Please note that only the outermost element <code>GetInboundResponseGetInboundSMS</code> belongs to a namespace <code>http://abcd.com</code> - the rest of the elements don't. How do I specify this in the XSD?</p>
  
  <p>I've tried with following XSD but that gives me error:</p>
  
  <p><strong>XSD:</strong></p>
  
  <pre><code>&lt;xs:schema attributeFormDefault="unqualified" 
             elementFormDefault="qualified" 
             xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
  &lt;xs:element name="GetInboundResponseGetInboundSMS"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
  
  &lt;xs:element name="response"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="messages"&gt;
            &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                &lt;xs:element name="item" 
                            maxOccurs="unbounded" minOccurs="0"&gt;
                  &lt;xs:complexType&gt;
                    &lt;xs:sequence&gt;
                      &lt;xs:element type="xs:string" name="date"/&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:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>But when I tried to validate the instance with the XSD using an online validator, I ended up with this error:</p>
  
  <blockquote>
    <p>Not valid.<br>
       Error - Line 1, 95: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 95; cvc-elt.1: Cannot find the declaration of element 'mes:GetInboundResponseGetInboundSMS'.</p>
  </blockquote>
  
  <p>Which is logical, as I did not provide the namespace in the XSD. Please help me understanding <strong>how do I provide this namespace ONLY FOR THE OUTERMOST ELEMENT in my XSD.</strong></p>