The xsd is here: http://www.iana.org/assignments/xml-registry/schema/epp-1.0.xsd
I don't want to modify the XSD (maintained by a third party) or the XJC generated classes since they get overwritten with every build.
Here is a sample snippet of the above XSD:
<complexType name="dcpAccessType">
<choice>
<element name="all"/>
...
</choice>
</complexType>
The corresponding XJC generated class looks like this:
...
public EppDcpAccessType {
...
public void setAll(Object value) { this.all = value; }
...
}
...
I want to generate an empty tag such as follows:
<all/>
But I don't know how to set the property to achieve this. If I do the following:
eppDcpAccessType.setAll("");
I get the following (with a bunch of attributes I don't want):
<all xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string"></all>
If I do the following:
eppDcpAccessType.setAll(new Object());
I get the following run time error:
java.lang.ClassCastException: java.lang.Object cannot be cast to org.w3c.dom.Element
How do I generate an empty tag without the attributes?
I had the very same problem. Third party XSD with a mandatory element without specified type.
I resolved it by using:
myJaxbType.setTheMandatoryElement(new org.dom4j.dom.DOMElement(""));
It yielded the outcome:
<TheMandatoryElement/>