Would like to create the following XML element using JAXB, no value(content), no closing element name, just closing '/' :
<ElementName attribute1="A" attribute2="B"" xsi:type="type" xmlns="some_namespace"/>
Trying the following
@XmlAccessorType(XmlAccessType.FIELD)
public class ElementName {
@XmlElement(name = "ElementName", nillable = true)
protected String value;
@XmlAttribute(name = "attribute1")
protected String attribute1;
@XmlAttribute(name = "attribute2")
protected String attribute2;
}
When constructing an object of this type as below, there is an exception
ElementName element = new ElementName();
What is the correct way of doing it ?
In case you want to achieve it for
ElementName
withvalue
set tonull
removenillable
attribute. Simple example how to generateXML
payload:prints: