I'm using JAXB to generate a bean model from a XML schema. One of the constructs in the schema is that a certain tag can be present or not. For example the ping in the sniplet below:
<buildtime-behavior>
<ping/>
</buildtime-behavior>
In the XSD I've mapped this as:
<xs:element name="buildtime-behavior">
<xs:complexType>
<xs:sequence>
<xs:element name="ping" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
And in the by JAXB generated BuildtimeBehavior class this results in:
public void setPing(Object value)
Now I want to set or clear that tag. However I cannot simply do a "new Object()" because that will result in a "java.lang.Object cannot be cast to org.w3c.dom.Element". But I have no Document to create a Element. The by JAXB generated ObjectFactory does not have a createPing() method...
How do I set ping?