title: JAXB generated classes of certain types implementing a custom interface
body: <p>I am working on an application that uses XJC to generate Java POJOs from XSDs.  There are dozens of schemas, and that number will grow.  The application also needs to be able to handle different versions of the same schema, which means that I will have multiple schemas defining common types.  I am trying to customize the bindings so that certain core types implement a common interface.  The Inheritance plugin of JAXB2 Basics seems to do what I need, but I can't seem to nail the right syntax.  </p>
  
  <p>Here is the relevant part of my schema:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:my="http://example.com/core"
             targetNamespace="http://example.com/core"
             xmlns:xml="http://www.w3.org/XML/1998/namespace"&gt;
  
      ...
  
      &lt;xs:complexType name="addressType"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="Address" type="xs:string"/&gt;
              &lt;xs:element name="City" type="xs:string"/&gt;
              &lt;xs:element name="Province" type="xs:string"/&gt;
              &lt;xs:element name="Country" type="xs:string"/&gt;
              &lt;xs:element name="County" type="xs:string" minOccurs="0"/&gt;
              &lt;xs:element name="PostalCode" type="xs:string"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  
      ...
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>... and this is what my custom binding file looks like:</p>
  
  <pre><code>    &lt;?xml version="1.0"?&gt;
  &lt;jaxb:bindings 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
      xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
      xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
      xmlns:my="http://example.com/core"
      jaxb:extensionBindingPrefixes="inheritance"
      version="2.1"&gt;
  
      &lt;jaxb:bindings scd="x-schema::my" xmlns:my="http://example.com/core"&gt;
          &lt;jaxb:globalBindings localScoping="toplevel"&gt;
              &lt;jaxb:serializable/&gt;
              &lt;xjc:simple/&gt;
          &lt;/jaxb:globalBindings&gt;
          &lt;jaxb:bindings scd="/type::my:addressType"&gt;
              &lt;inheritance:implements&gt;com.mysite.validator.ValidatableAddress&lt;/inheritance:implements&gt; 
              &lt;!--&lt;xjc:superInterface name="com.mysite.validator.ValidatableAddress"/&gt;--&gt;
          &lt;/jaxb:bindings&gt;
      &lt;/jaxb:bindings&gt;
  
  &lt;/jaxb:bindings&gt;
  </code></pre>
  
  <p>I'm using the <em>scd</em> approach, because in all the "traditional" binding examples that show how to use the inheritence plugin, <em>schemaLocation</em> is specified.  I want to avoid having to specify <em>schemaLocation</em> because of our large (and growing) number of schemas.  I don't want to have to change the binding file every time we add a new schema.  So, <em>scd</em> seems like it will satisfy this requirement.  </p>
  
  <p>However when I run the build using the above binding, I get this:</p>
  
  <blockquote>
  <pre><code>  [xjc] [ERROR] cvc-elt.1: Cannot find the declaration of element 'inheritance:implements'.
    [xjc]   line 18 of file:/dev/workspace/my_app/etc/schemas/bindings-common.xml
    [xjc] failure in the XJC task. Use the Ant -verbose switch for more details
    [xjc] classLoader = java.net.URLClassLoader@ebcdbb
    [xjc] SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@14562c5
  </code></pre>
  </blockquote>
  
  <p>If I comment out the <strong>inheritance:implements</strong> line and uncomment the <strong>xjc:superInterface</strong> line, the error goes away and the build completes successfully, but my <em>AddressType</em> classes don't implement the ValidatableAddress type.</p>
  
  <p>Can the inheritence plugin be used with <em>scd</em>?  Can xjc:superInterface be limited to only certain elements?</p>
  
  <p>Cheers.</p>