title: JAXB generating wrong Namespace
body: <p>I have a xsd (lets name it as afb) which imports another xsd (lets name it as kts). And I refer to an element of kts.xsd in afb.xsd along with correct namespaces.</p>
  
  <p>But when I generate the classes using JAXB, the namespace for refered element is wrong.</p>
  
  <p>I mean, the referred element should have kts namespace where as it is having afb namespace.</p>
  
  <p>Because of which validating my XML against this xsd is failing also not able to bind the xml data into the java models.</p>
  
  <p>EX:
  afb.xsd : </p>
  
  <pre><code>&lt;xs:import namespace="http://www.boschkts.com" schemaLocation="kts.xsd"/&gt;
  &lt;xs:element name="vehicle"&gt;
  
  &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element ref="vType"/&gt;
            &lt;xs:element name="RESULTS" type="kts:RESULTS" &gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>kts:xsd : </p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.boschkts.com" 
  targetNamespace="http://www.boschkts.com" elementFormDefault="qualified"&gt;
  
  &lt;xs:complexType name="RESULTS"&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element name="SUMMARY" type="SUMMARY" minOccurs="0" /&gt;
      &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>Vehicle.java : </p>
  
  <pre><code>public class Vehicle {
  
      @XmlElement(namespace = "http://www.boschafb.com", required = true)
      protected String vType;
      @XmlElement(name = "RESULTS", namespace = "http://www.boschafb.com", required = true)
      protected Results results;
  
  }
  </code></pre>
  
  <p>If I observe the Vehicle.java, the namespace of results property should have been "http://www.bosch<b>kts</b>.com" instead of "http://www.boschafb.com"</p>
  
  <p>If I change the namespace manually then binding the data from xml to java models works.
  But still validating against the xsd fails with the error : </p>
  
  <blockquote>
    <p>Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'kts:RESULTS'. One of '{"http://www.boschafb.com":RESULTS}' is expected.</p>
  </blockquote>
  
  <p>Can anybody point what I might be missing in the xsd? or is it the way jaxb generates and I have to modify the classes manually?</p>
  
  <p>Regards,</p>
  
  <p>Satya</p>