title: JAXB multiple XSDs in input and duplicate types
body: <p>I am trying to generate Java code for two XSDs (let's say request.xsd and response.xsd) using JAXB</p>
  
  <p>Request.xsd includes A.xsd which defines a complex type "FOO"</p>
  
  <p>Response.xsd includes B.xsd which defines a complex type "FOO" too (different type with the same name). </p>
  
  <p>Initially, I thought of adding to both XSDs something like in order to fix the name clash. </p>
  
  <pre><code>&lt;xsd:annotation&gt;
     &lt;xsd:appinfo&gt;
        &lt;jaxb:class name="AFOO"/&gt; (and BFOO)
     &lt;/xsd:appinfo&gt;
  &lt;/xsd:annotation&gt;
  </code></pre>
  
  <p>However, I still get the error that "FOO" is already defined. If I try to generate code only for request.xsd or only for response.xsd the code is generated correctly. </p>
  
  <p>My initial pom.xml looks like:</p>
  
  <pre><code>   &lt;plugin&gt;
              &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt;
              &lt;version&gt;0.8.2&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;generate&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;debug&gt;true&lt;/debug&gt;
                  &lt;schemaDirectory&gt;src/main/resources/xsds&lt;/schemaDirectory&gt; 
                  &lt;generateDirectory&gt;src/main/generated&lt;/generateDirectory&gt;
                  &lt;generatePackage&gt;com.mycompany.generated&lt;/generatePackage&gt; 
                  &lt;extension&gt;true&lt;/extension&gt;
                  &lt;markGenerated&gt;true&lt;/markGenerated&gt;
                  &lt;args&gt;
                      &lt;arg&gt;-camelcase-always&lt;/arg&gt;
                      &lt;arg&gt;-XtoString&lt;/arg&gt;
                      &lt;arg&gt;-Xequals&lt;/arg&gt;
                      &lt;arg&gt;-XhashCode&lt;/arg&gt;
                      &lt;arg&gt;-Xsetters&lt;/arg&gt;
                  &lt;/args&gt;
                  &lt;plugins&gt;
                      &lt;plugin&gt;
                          &lt;groupId&gt;org.jvnet.jaxb2_commons&lt;/groupId&gt;
                          &lt;artifactId&gt;jaxb2-basics&lt;/artifactId&gt;
                          &lt;version&gt;0.6.4&lt;/version&gt;
                      &lt;/plugin&gt;
                      &lt;plugin&gt;
                          &lt;groupId&gt;org.andromda.thirdparty.jaxb2_commons&lt;/groupId&gt;
                          &lt;artifactId&gt;camelcase-always&lt;/artifactId&gt;
                          &lt;version&gt;1.0&lt;/version&gt;
                      &lt;/plugin&gt;
                  &lt;/plugins&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>Eventually, I managed to get it to work using different executions for request and response. </p>
  
  <pre><code>&lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;Output&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;generate&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;forceRegenerate&gt;true&lt;/forceRegenerate&gt;
                              &lt;debug&gt;true&lt;/debug&gt;
                              &lt;schemaDirectory&gt;src/main/resources/xsds&lt;/schemaDirectory&gt; 
                              &lt;generateDirectory&gt;src/main/generated&lt;/generateDirectory&gt;
                              &lt;schemaIncludes&gt;
                                  &lt;include&gt;
                              response.xsd
                                  &lt;/include&gt;
                              &lt;/schemaIncludes&gt; 
                              &lt;generatePackage&gt;com.mycompany.generated.reply&lt;/generatePackage&gt;
                              ....
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
  
                      &lt;execution&gt;
                          &lt;id&gt;Input&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;generate&lt;/goal&gt;
                          &lt;/goals&gt;
  
                          &lt;configuration&gt;
                              &lt;forceRegenerate&gt;true&lt;/forceRegenerate&gt;
                              &lt;debug&gt;true&lt;/debug&gt;
                              &lt;schemaDirectory&gt;src/main/resources/xsds&lt;/schemaDirectory&gt; 
                              &lt;generateDirectory&gt;src/main/generated&lt;/generateDirectory&gt;
                              &lt;schemaIncludes&gt;
                                  &lt;include&gt;
                              request.xsd
                                  &lt;/include&gt;
                              &lt;/schemaIncludes&gt; 
                              &lt;generatePackage&gt;com.mycopnay.generated.query&lt;/generatePackage&gt;
                              ...
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
  </code></pre>
  
  <p>In this way, it works. However I have the following questions:</p>
  
  <ul>
  <li>Is there any better way to make it work without modifying the xsd? A lot of classes are shared between request and response are generated twice (under different java packages). Is there any way to reuse them?</li>
  <li>Why overriding the class name (my initial solution) does not work?</li>
  </ul>