title: JAXB xjc mapping to existing domain objects
body: <p>I have done a lot of searching and cannot find a concise example of how to map an XML schema to existing domain objects instead of creating brand new ones utilizing <em>xjc</em>.  I have created a bindings (xjb) file but still can find no way of accomplishing this.</p>
  
  <p>If I have an existing domain Object that I want JAXB to use such as the following:</p>
  
  <pre><code>package com.blah.domain;
  class CustomerOffice{
     private int id;
     private String name;
     private String phone;
  }
  </code></pre>
  
  <p>And I have an XML Schema like the following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns:www="http://www.blah.com" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  targetNamespace="http://www.blah.com" elementFormDefault="unqualified"&gt;
     &lt;xs:element name="Customer"&gt;
        &lt;xs:complexType&gt;
           &lt;xs:sequence&gt;
             &lt;xs:element name="id" type="xs:int" nillable="false" minOccurs="1" maxOccurs="1"/&gt;
             &lt;xs:element name="name" type="xs:string"/&gt;
             &lt;xs:element name="city" type="xs:string"/&gt;
             &lt;xs:element name="CustomerOffice" type="www:CustomerOffice" maxOccurs="unbounded"/&gt;
          &lt;/xs:sequence&gt;
       &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;
     &lt;xs:complexType name="CustomerOffice"&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="name" type="xs:string"/&gt;
          &lt;xs:element name="length" type="xs:int"/&gt;
        &lt;/xs:sequence&gt;
     &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>If I go to generate the JAXB classes with <em>xjc</em> it will create a new class called <em>Customer</em> (which I want).  It will also create a new class called <em>CustomerOffice</em> (which I don't want, I want it to use my existing domain object).</p>
  
  <p>So instead of the schema pointing to "type:www:CustomerOffice" I would want it to use the existing <em>com.blah.domain.CustomerOffice</em>.</p>
  
  <p>I tried to make this as simple an example as possible, any help is appreciated.</p>