I've a requirement to bind the XML content to String attribute of my pojo, and for that I've created my custom DomHandler to extract required part, something like below
<sample>
<color>red</color>
<content>
<p>here is content <b>with bold</b></p>
</content>
</sample>
Which will map to pojo
@XmlRootElement
class Sample {
@MyCustomAnnotation(value="abcde")
@XmlElement(name="color")
private String color;
@MyCustomAnnotation(value="12345")
@XmlElement(name="content")
@XmlAnyElement(ContentHandler.class)
private String content;
}
I'm generating my pojos using XSD, also I've couple of custom annotations to be added to generated pojos so for that I'm using maven-jaxb2-plugin.
The problem is, it adds annotations as required along with @XmlElement which is mutually exclusive to @XmlAnyElement, is there any way to avoid adding @XmlElement annotation using XSD?