Note that there are some explanatory texts on larger screens.

plurals
  1. PO@XmlElements marked with @XmlJavaTypeAdapters?
    text
    copied!<p>I have this situation</p> <pre><code>@XmlType(name ="", propOrder={"value"}) @XmlRootElement(name = "compound") public class Compound extends Value { @XmlElements({ @XmlElement(name="simple", type=Simple.class), @XmlElement(name="compound", type=Compound.class) }) protected List&lt;Value&gt; value; // ... } </code></pre> <p>So a Compound is a List of both Simple and/or Compound. Both extend from Value that is defined as</p> <pre><code>public abstract class Value implements Serializable {} </code></pre> <p>Simple is a class marked with an adapter to marshal/unmarshal to/from a simple string</p> <pre><code>@XmlJavaTypeAdapter(SimpleAdapter.class) public class Simple extends Value { private java.lang.String simple; // ... } </code></pre> <p>Compound does not need an adapter.</p> <p>The problem is that if I use a Simple 'as is', it correctly marshals/unmarshals as</p> <pre><code>&lt;simple&gt;my.text.here&lt;/simple&gt; </code></pre> <p>but if I use it inside a Compound it outputs something like</p> <pre><code>&lt;compound&gt; //... &lt;simple&gt; &lt;value&gt;my.text.here&lt;/value&gt; &lt;/simple&gt; //... &lt;/compound&gt; </code></pre> <p>And I'm just wondering why... Do I miss something? How can i remove that 'value'? It seems to me that the Adapter is not used at all, is it possible to use adapters in types marked inside @XmlElements?</p> <p><strong>EDIT</strong></p> <p>After few tests i found that the problem could be in how i handle a Simple instance. So I simplify my initial question in:</p> <p>Given the a Simple class like</p> <pre><code>@XmlRootElement("simple") public class Simple { private java.lang.String innerText; // getters/setters } </code></pre> <p>how can i obtain a marshalled output like</p> <pre><code>&lt;simple&gt; my.inner.text.here &lt;/simple&gt; </code></pre> <p>instead of</p> <pre><code>&lt;simple&gt; &lt;value&gt;my.inner.text.here&lt;/value&gt; &lt;/simple&gt; </code></pre> <p>?</p>
 

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