title: Xml schema interfaces
body: <p>I'm attempting to write an XML schema to define some model classes to be used in jaxb in java.</p>
  
  <p>I would like to be able to define an interface in the xsd but I've no idea how to do this.</p>
  
  <p>For example a lot of my classes will have an attribute called id which is type xs:ID. They will have an attribute called ref which is type xs:IDREF and they will have an attribute called extRef which means that there is a refrence but the element is not specified in the given xml file. </p>
  
  <p>Ideally this would be an interface when converted to java for two reasons. </p>
  
  <ol>
  <li>The classes that implement this are not necessarily connected.</li>
  <li>I would like to specify a different inheritance tree for some of these objects.</li>
  </ol>
  
  <p>Example:</p>
  
  <pre><code>&lt;!-- Utility type to be externally referenceable this is too keep all the 
      externally refrencable attributes in check --&gt;
  &lt;xs:complexType name="ExternallyReferenceable" abstract="true"&gt;
      &lt;xs:attribute name="extRef" type="externalReference" /&gt;
      &lt;xs:attribute name="id" type="xs:ID" /&gt;
      &lt;xs:attribute name="ref" type="xs:IDREF" /&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="ExternalCarPart"&gt;
      &lt;xs:extension base ="ExternallyReferenceable" /&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="CarPart"&gt;
      &lt;xs:extension base ="ExternalCarPart"&gt;
                       &lt;xs:sequence&gt;
                               &lt;xs:element type="xs:string" name="partName" /&gt;
                       &lt;/xs:sequence&gt;
      &lt;/xs:extension&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="CarLamp"&gt;
      &lt;xs:extension base ="ExternalCarPart"&gt;
                       &lt;xs:sequence&gt;
                               &lt;xs:element type="xs:string" name="glassPurity" /&gt;
                       &lt;/xs:sequence&gt;
              &lt;/xs:extension&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>So in the above example it would be better if exteranllyRefrencable was an interface, and if carpart was an interface.</p>
  
  <p>This would allow CarLamp to inherit from lamp rather than external car part. BicycleLamp could also implement the externallyRefrencable interface and extend lamp also.</p>
  
  <p>Please ask me for clarification if the question isn't clear.</p>