I have such a situation.
@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<Value> value;
Thus, a compound is a list of both simple and / or compound. Both of them extend from a value that is defined as
public abstract class Value implements Serializable {}
Simple is the class marked with the adapter for marshal / unmarshal to / from a simple string.
@XmlJavaTypeAdapter(SimpleAdapter.class) public class Simple extends Value { private java.lang.String simple;
The connection does not need an adapter.
The problem is that if I use Simple 'as is', it will correctly marshal / non-marshals like
<simple>my.text.here</simple>
but if I use it inside Compound, it outputs something like
<compound> //... <simple> <value>my.text.here</value> </simple> //... </compound>
And I'm just wondering why ... Am I missing something? How can I remove this value? It seems to me that the adapter is not used at all, is it possible to use adapters in the types marked inside @XmlElements?
EDIT
After several tests, I found that the problem might be how I handle a simple instance. Therefore, I simplify my initial question in:
Given a simple class like
@XmlRootElement("simple") public class Simple { private java.lang.String innerText;
how can i get marshalled output like
<simple> my.inner.text.here </simple>
instead
<simple> <value>my.inner.text.here</value> </simple>
?