I have classes defined as:
@XmlRootElement( name = "RootNode" )
public class RootNode{
.....
@XmlElement( name = "code", required = true )
protected CodeWord code;
@XmlElement( name = "text" )
protected EncText text;
.....
}
While class EncText looks like:
@XmlType( name = "EncText ",
propOrder = {
"language"
} )
public class EncText {
.....
@XmlElement( name = "language" )
protected LANG language;
@XmlAttribute( name = "mediaType" )
@XmlJavaTypeAdapter( CollapsedStringAdapter.class )
protected String mediaType;
.....
}
In the EncText, I might have text data which need to be added as the text node. I would like to have output, after marshalling, like:
<RootNode>
<text mediaType="plain/text">
Data come from database.
</text>
</RootNode>
How can I define property in, say EncText, as well proper setter and getter to allow me to do so? I tried to define a @XmlValue property in EncText. However, error showed that XmlElement can not coexist with XmlValue. I need advices for this. Thanks a lot.