The size and complexity of the payload have immense impact on the performance. If the payload is huge and complex it would affect the performance as it takes long time to parse the content.
It is often observed that the payload usually has many fields with only a few being populated. Reducing the payload to include only the fields with values would help to reduce the network traffic and increase the processing speed. This can be achieved by explicitly setting the minOccurs value to 0.By default this is set to 1 in XSD.
The following example shows the definition of Meal type schema.
<xs:element name="mealType">
<xs:complexType>
<xs:sequence>
<xs:element name="category"
type="xs:string"/>
<xs:element
name="starter" minOccurs="0"
maxOccurs="1"
type="xs:int"/>
<xs:element name="mainCourse"
minOccurs="1" maxOccurs="3" type="xs:string"/>
<xs:element name="dessert" minOccurs="0"
maxOccurs="2"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
(i) A sample payload with all fields populated would be as follows:
<mealType>
<category>Executive Lunch </category>
<starter>samosa </starter>
<mainCourse>Rice <mainCourse>
<mainCourse>Naan <mainCourse>
<dessert>Ice cream </dessert>
</mealType>
(ii )A sample payload with only few fields populated would be as follows:
<mealType>
<category>Budget
Lunch </category>
<mainCourse>Rice
<mainCourse>
</mealType>
No comments:
Post a Comment