Hello!
I try to deserialize some xml. I wrote custom serializer class
MaterialSerializer extending BaseSerializer with overrided function
deserialize();
Class for deserializing:
[XmlClass(alias="flow", uri="
http://www.imsglobal.org/xsd/
ims_qtiasiv1p2")]
public class Flow {
[MaterialElement]
public var material:CustomMaterial;
[ArrayElementType("com.gmat.model.qti.Flow")]
[XmlArray(alias="flow", type="com.gmat.model.qti.Flow")]
public var flowArray:Array;
public function Flow() {
}
}
I done custom annotation:
public class MaterialElement extends XmlMember
I register custom annotation with context:
var context:DescriptionContext =
FxBEngine.instance.getXmlSerializer().context;
context.registerAnnotation("MaterialElement", MaterialElement,
MaterialSerializer);
But when method deserialize of custom serializer invokes in its
argument named serializedData there is an xml contains not only
<material> element and its children, but larger xml like this:
<flow width="700" xmlns="
http://www.imsglobal.org/xsd/ims_qtiasiv1p2"
xmlns:pearsonvue="
http://www.vue.com/schemas" xmlns:vantage="http://
www.vantage.com/schemas/vantage">
<flow border="1,1,1,1" inset="0,0,0,0" orientation="horizontal">
<flow inset="0,0,0,0" width="140">
<flow height="43" inset="2,2,0,0">
<material>
<mattext>
<p align="center" style="white-space: pre-wrap; ">Must
happen in the location</p>
</mattext>
</material>
</flow>
<flow inset="0,0,0,0" orientation="vertical">
<response_lid ident="211:000508-RO-R01" rcardinality="single">
<render_choice>
<flow_label border="1,0,0,0" height="24" inset="4,60,0,0">
<response_label ident="A" valign="middle"/>
</flow_label>
<flow_label border="0,0,0,0" height="24" inset="4,60,0,0">
<response_label ident="B" valign="middle"/>
</flow_label>
</render_choice>
</response_lid>
</flow>
</flow>
<flow inset="0,0,0,0" width="140">
<flow border="0,1,0,0" height="43" inset="2,2,0,0">
<material>
<mattext>
<p align="center" style="white-space: pre-wrap; ">Must not
happen in the
location</p>
</mattext>
</material>
</flow>
<flow inset="0,0,0,0" orientation="vertical">
<response_lid ident="211:000508-RO-R02" rcardinality="single">
<render_choice>
<flow_label border="1,1,0,0" height="24" inset="4,60,0,0">
<response_label ident="A" valign="middle"/>
</flow_label>
<flow_label border="0,1,0,0" height="24" inset="4,60,0,0">
<response_label ident="B" valign="middle"/>
</flow_label>
</render_choice>
</response_lid>
</flow>
</flow>
<flow inset="0,0,0,0" orientation="vertical" width="418">
<flow border="0,1,0,0" height="43" inset="10,2,0,0">
<material>
<mattext>
<p align="center" style="white-space: pre-wrap;
">Activities of the members of
the species</p>
</mattext>
</material>
</flow>
<flow border="1,1,0,0" height="24" inset="2,5,0,0">
<material>
<mattext>Sleeping</mattext>
</material>
</flow>
<flow border="0,1,0,0" height="24" inset="2,5,0,0">
<material>
<mattext>Occupying the location multiple times</mattext>
</material>
</flow>
</flow>
</flow>
<flow inset="0,0,0,0"/>
</flow>
I should do some things with content of <material> in serializer but I
can't cause serializer is called once for the whole part of xml like
above not for each <material> entry.
Question: Is it possible to call serializer for each element entry and
get in serializedData argument only content of element like below?
<mattext>
<p align="center" style="white-space: pre-wrap; ">Must happen in
the location</p>
</mattext>
Sorry for complex explanation, may be i didn't properly understand
using custom serializers.