title: Jaxb validation against schema with only complex types
body: <p>I have a wsdl that contains request and response elements:</p>
  
  <pre><code>&lt;xsd:element name="someRequest" type="ns:SomeRequest"/&gt;
  
  &lt;xsd:element name="someResponse" type="ns:SomeResponse"/&gt;
  </code></pre>
  
  <p>This wsdl imports a few xsd's, which contain, among others, these complexTypes:</p>
  
  <pre><code>&lt;xsd:complexType name="SomeRequest"&gt;
      ...
  &lt;/xsd:complexType&gt;
  
  &lt;xsd:complexType name="SomeResponse"&gt;
      ...
  &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>I want to validate an xml against this wsdl, but I can't get it to work. I'm basically using the method described on <a href="http://actimem.com/java/jaxb-validation/#Marshalling_Validation" rel="noreferrer">http://actimem.com/java/jaxb-validation/#Marshalling_Validation</a>, by marshalling the object and setting a Schema and EventHandler.</p>
  
  <p>If I set the Schema to the xsd, it won't validate because there's no element in the xsd. This is pretty logical, I get the same with other tools. When I use the wsdl as Schema, I get this error because of inline documentation:</p>
  
  <pre><code>s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'.
  </code></pre>
  
  <p>Is there any way to get this to validate? </p>
  
  <p>Since I'm working on existing projects (currently using Xmlbeans instead of JAXB) with a set workflow, I have to work with a few constraints:</p>
  
  <ul>
  <li>These schemas were not made by us and can't be edited, so removing the docs or adding the elements isn't an option.</li>
  <li>I would prefer to load the xsd's from 1 place because of duplication and possible human errors. Xsd's are stored in a separate project, which builds jars we include as dependencies in our projects. The jars that contain the xjc generated classes also contain the schemas. </li>
  <li>The xsd's contain a lot of imports.</li>
  <li>Because of namespacing and classloading collisions, I can't use the ObjectFactory generated by xjc. Multiple xsd's have the same namespace but are actually different, and this has caused issues with the wrong ObjectFactory getting loaded in generic projects that use multiple xsd's.</li>
  </ul>
  
  <p>I've tried transforming the schema to add the element manually, but I can't find a way to do it on an existing Schema object. If I do this through DOM manipulation, I get the new schema as a String object, which won't parse into a Schema because the imported xsd's can't be found.</p>
  
  <p>If I copy the xsd's from the jar to the project, I can transform them and get the validation to succeed, but I don't really like this solution. If there's no other way, I'll revert to that, but I would like to find a solution that requires as little work as possible when reusing this method and is the least prone to errors. Other developers will use this code and 1 validate method without needing extra steps to work would be perfect.</p>
  
  <p>I ran into basically this problem before and didn't find a solution then, either. But before, the complexType wasn't the root element and I could just wrap it into other objects until I found an object that was represented as element in the xsd.</p>