title: How to call same method between two class packages that share certain code
body: <p>I have 2 auto-generated packages (generated by JAXB) from XML schema's that are controlled by a third party. They have sections of their XML definitions that are identical. Some of those sections I will be using to gather information for processing the XML. How can I go about this to reduce the amount of code duplication?</p>
  
  <p>I want to be able to create methods I can call more generically. The following would be an example of the two methods that have been generated:</p>
  
  <pre><code>com.example.xml1 o = (com.example.xml1) u.unmarshal(document);
  String type1 = o.getRoot().getType();
  com.example.xml2 o = (com.example.xml2) u.unmarshal(document);
  String type2 = o.getRoot().getType();
  </code></pre>
  
  <p>Is there a method I can use where I could get the object and call:</p>
  
  <pre><code>// magic somewhere in here
  //Object o = u.unmarshal(document);
  String type = o.getRoot().getType();
  </code></pre>
  
  <p>I won't know the XML type until I am able to read that part.  Would using xPath to read the form type and then branching based on that be the best way to do this?</p>