Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately, it looks like the interface-injection plugin mentioned in some of the other answers is no longer well-supported. In fact, I'm having trouble finding the JAR for download.</p> <p>Thankfully, the <a href="http://confluence.highsource.org/display/J2B/JAXB2+Basics+Plugins" rel="noreferrer">JAXB2 Basics Plugins</a> provides a similar mechanism for adding an interface to the generated JAXB stubs (see the <a href="http://confluence.highsource.org/display/J2B/Inheritance+plugin" rel="noreferrer">Inheritance plugin</a>). </p> <p>The Inheritance plugin documentation has an example showing what the XML schema file might look like. However, since you cannot modify the schema, you can use an external bindings file instead:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0"?&gt; &lt;jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" jxb:extensionBindingPrefixes="xjc"&gt; &lt;jxb:bindings schemaLocation="xsd/adult.xsd"&gt; &lt;jxb:bindings node="//xs:complexType[@name='Person']"&gt; &lt;inheritance:implements&gt;mypackage.Hello&lt;/inheritance:implements&gt; &lt;/jxb:bindings&gt; &lt;/jxb:bindings&gt; &lt;/jxb:bindings&gt; </code></pre> <p>The JAXB2 Basics Plugins documentation includes instructions for using the plugin with Ant and Maven. You can also use it straight from the command line, but the command is a bit messy (due to the number of jars you have to add to the classpath):</p> <pre class="lang-none prettyprint-override"><code>java -jar jaxb-xjc.jar -classpath jaxb2-basics-0.5.3.jar,jaxb2-basics-runtime-0.5.3.jar, jaxb2-basics-tools-0.5.3.jar,commons-beanutils-0.5.3.jar, commons-lang.jar,commons-logging.jar -p mypackage.myxml -extension -Xinheritance xsd/adult.xsd -b binding.xjb </code></pre> <p>The JAXB2 Basics Plugins provides a number of other utilities which you might also find useful (such as autogeneration of equals, hashCode, and toString methods).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload