Input XML
<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<firstname xsi:nil=true/>
</employee>
Output Object State
anEmployee.getFirstname() = null
anEmployee.isSet(firstname) = true
Marshal null composite object (isSet=true) as empty node: .
Code Sample
XMLDescriptor aDescriptor = new XMLDescriptor();
aDescriptor.setJavaClass(Team.class);
aDescriptor.setDefaultRootElement("team");
XMLCompositeObjectMapping aManagerMapping = new XMLCompositeObjectMapping();
aManagerMapping.setAttributeName("manager");
aManagerMapping.setXPath("manager/text()");
// do not modify the default NullPolicy or the 3 boolean flags
AbstractNullPolicy aNullPolicy = afirstNameMapping.getNullPolicy();
aDescriptor.addMapping(aManagerMapping);
aNullPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
Input Object State
aTeam.getManager() = null
aTeam.isSet(manager) = no effect
Output XML
<team xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@see org.eclipse.persistence.internal.oxm.NullCapableValue
@since Oracle TopLink 11g Release 1 (11.1.1)
<manager/>
</team>
|
|