| Issue 55: | Patch to support xsi:nil and XmlMember 'required' in serialization | |
| 1 person starred this issue and may be notified of changes. | Back to list |
HI Alex, The XSD format allows nillable elements (xsi:nil="true") in the form <item xsi:ni="true" /> Current implementation doesn't support this feature, and skips any member properties that are null during serialization. Patch attached (with tests): - adds 'isRequired' property to IMemberAnnotation (default is false obviously) - adds 'nillable' property to XmlElement annotation and set isRequired to true if nillable is true - change to SerializationCore.doSerialize to pass null objects through to serializer if IMemberAnnotation(annotation).isRequired is true - change to XmlElementSerializer to check for null object and if nillable="true" then add the xsi:nil attribute and xsi namespace to the node;
Sep 30, 2011
(No comment was entered for this change.)
Labels:
-Type-Defect Type-Enhancement
Oct 3, 2011
HI Alex,
Just noticed that the provided patch doesn't cater for XmlElement deserialization handling incoming elements with xsi:nil.
XmlEleemntSerializer.deserializeObject
Add check for xsi:nil:
if(XmlElement(element).nillable && xml.@[XmlUtils.xsiNil] == "true")
{
return null;
}
Added the following to the xsiNil test in XmlSerializerTest
item = new NillableData();
xml = FlexXBEngine.instance.serialize(item);
var copy:NillableData = FlexXBEngine.instance.deserialize(xml, NillableData);
assertNull(copy.elementNillable);
Apr 14, 2012
(No comment was entered for this change.)
Status:
Fixed
|
Labels: Milestone-2.3.1