My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
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
Status:  Fixed
Owner:  ----
Closed:  Apr 2012


 
Reported by domdelor...@gmail.com, Sep 29, 2011
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;


flexxb_xsinil_patch.txt
17.7 KB   View   Download
Sep 30, 2011
Project Member #1 alex.id....@gmail.com
(No comment was entered for this change.)
Status: Accepted
Labels: Milestone-2.3.1
Sep 30, 2011
Project Member #2 alex.id....@gmail.com
(No comment was entered for this change.)
Labels: -Type-Defect Type-Enhancement
Oct 3, 2011
#3 domdelor...@gmail.com
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
Project Member #4 alex.id....@gmail.com
(No comment was entered for this change.)
Status: Fixed

Powered by Google Project Hosting