I'm using JAXB for quick-and-dirty XML generation. I have a class that represents a tree structure:
@XmlRootElement(name = "element")
public class Element {
// [...]
@XmlElementWrapper(name="childs")
@XmlElementRef
public List<Element> getChilds() { /*...*/ }
}
I want to restrict the depth up to which the child collection is marshalled. So, for example I'd like to write out just the direct childs of the element I send to the Marshaller but omit their childs.
Is there a standard JAXB way to do this or maybe a callback I can use to disable the marshalling of a property on the fly?