Is it possible to ignore a wrapper class during JAXB marshalling

KseniyaK

New Member
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.\[code\]@XmlType(name = "root")@XmlRootElement(name = "root")public class Root { @XmlElementRef private List<Resource> resources = new ArrayList<>(); 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\]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. This is what I currently have:\[code\]<root> <> <element name="resource1"/> <fieldType name="resource1--type"> </fieldType> <listType name="resource--list"> </listType> </> <> <element name="resource2"/> <fieldType name="resource2--type"> </fieldType> <listType name="resource2--list"> </listType> </></root>\[/code\]What I'd like to achieve is the following:\[code\]<root> <element name="resource1"/> <fieldType name="resource1--type"> </fieldType> <listType name="resource--list"> </listType> <element name="resource2"/> <fieldType name="resource2--type"> </fieldType> <listType name="resource2--list"> </listType></root>\[/code\]I don't know if it's possible, but any help would be appreciated.Thanks.
 
Back
Top