Note that there are some explanatory texts on larger screens.

plurals
  1. POJAXB multiple schemas with element reference
    primarykey
    data
    text
    <p>I have two schemas which are processed using JAXB. The first schema is preprocessed and information of this is used using an episode file (following <a href="http://www.java.net/blog/2006/09/05/separate-compilation-jaxb-ri-21" rel="noreferrer">http://www.java.net/blog/2006/09/05/separate-compilation-jaxb-ri-21</a>). The second schema imports the first, and again using jaxb, is processed. This all works as expected.</p> <p>But now I have an element in the first schema, which is used in the second using a reference.</p> <p><strong>Schema a:</strong></p> <pre><code>&lt;schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:test="http://www.example.org/Test/" targetNamespace="http://www.example.org/Test/"&gt; &lt;element name="type" type="test:MyType"&gt;&lt;/element&gt; </code></pre> <p><strong>Schema b:</strong></p> <pre><code>&lt;schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:second="http://www.example.org/Second/" xmlns:test="http://www.example.org/Test/" targetNamespace="http://www.example.org/Second/"&gt; &lt;import namespace="http://www.example.org/Test/" /&gt; &lt;complexType name="SomeType"&gt; &lt;sequence&gt; &lt;element ref="test:type" minOccurs="1" maxOccurs="unbounded" /&gt; &lt;/sequence&gt; &lt;/complexType&gt; </code></pre> <p>During processing nothing is wrong, but the generated code for both schemas provide the same method:</p> <pre><code>public JAXBElement&lt;EventType&gt; createType(TypeType value) </code></pre> <p>At runtime, this results in the following error:</p> <pre><code>com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions The element name {http://www.example.org/Type/}type has more than one mapping. </code></pre> <p>How can I prevent JAXB from creating the duplicate createType methods?</p> <p>Thanks in advance!</p> <p>Update: I asked this same question on the JAXB mailing list, on that list I also posted a working example. The thread and example can be found at: <a href="http://java.net/projects/jaxb/lists/users/archive/2011-03/message/18" rel="noreferrer">http://java.net/projects/jaxb/lists/users/archive/2011-03/message/18</a></p> <p>On this list I've been suggested a workaround, and now I can use the schemas the way I like. But I still think JAXB should not create the additional "create" method, since it should already be in the episode file.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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