Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to ignore a wrapper class during JAXB marshalling
    primarykey
    data
    text
    <p>I'm trying to get JAXB to ignore a wrapper class during the Mashalling process, it makes sense to have this wrapper class in code, as it keep all related information together, however I need to get rid of it during the marshaling process. The following is the relevant code.</p> <pre><code>@XmlType(name = "root") @XmlRootElement(name = "root") public class Root { @XmlElementRef private List&lt;Resource&gt; resources = new ArrayList&lt;&gt;(); public void addResource(Resource resource) { resources.add(resource); } } @XmlRootElement(name = "", namespace = "") @XmlAccessorType(XmlAccessType.NONE) public class Resource { @XmlElementRef private Element element; @XmlElementRef private FieldType fieldType; @XmlElementRef private ListType listType; } </code></pre> <p>Root is the main object, and Resource is the wrapper object that I'd like not have a node created for. I still want the Element, FieldType and ListType within the Resource to be rendered however. </p> <p>This is what I currently have:</p> <pre><code>&lt;root&gt; &lt;&gt; &lt;element name="resource1"/&gt; &lt;fieldType name="resource1--type"&gt; &lt;/fieldType&gt; &lt;listType name="resource--list"&gt; &lt;/listType&gt; &lt;/&gt; &lt;&gt; &lt;element name="resource2"/&gt; &lt;fieldType name="resource2--type"&gt; &lt;/fieldType&gt; &lt;listType name="resource2--list"&gt; &lt;/listType&gt; &lt;/&gt; &lt;/root&gt; </code></pre> <p>What I'd like to achieve is the following:</p> <pre><code>&lt;root&gt; &lt;element name="resource1"/&gt; &lt;fieldType name="resource1--type"&gt; &lt;/fieldType&gt; &lt;listType name="resource--list"&gt; &lt;/listType&gt; &lt;element name="resource2"/&gt; &lt;fieldType name="resource2--type"&gt; &lt;/fieldType&gt; &lt;listType name="resource2--list"&gt; &lt;/listType&gt; &lt;/root&gt; </code></pre> <p>I don't know if it's possible, but any help would be appreciated.</p> <p>Thanks.</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.
    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