Complex Element
Complex Element : which element contains simple elements or
other complex elements is call complex element.
We can create complex elements in two ways in xsd
1.creating complex type elements and using them
2.annoums complex element
1.creating complex type elements and using them
we can create a complex element in xsd by using
"complexType" key word
as follows
we can resue the structure of the complex type (it is
creating class in java)
compareing java class and complex type in xsd.
Class in java
|
Complex Type in xsd
|
Class name_of_class
{
//statements
}
|
<complexType name=”name_of_complex _type”>
<sequence/all>
//simple
elements
</sequence/all>
</complexType>
|
class ItemType
{
String itemcode;
int quantity;
}
|
<complexType name="itemtype">
<sequance>
<element
name="itemcode" type="string"/>
<element
name="quantity" type="int"/>
</sequance>
</complexType>
|
ItemType item=new ItemType();
|
<element name=”item” type=”itemtype”>
|
Structure:
<complexType name="complex_type_name">
<sequance/all>
//simple
elements or complex elements
</sequance/all>
</complexType>
Example:
complexType which contains simple elements
<complexType name="itemtype">
<sequance>
<element
name="itemcode" type="string"/>
<element
name="quantity" type="int"/>
</sequance>
</complexType>
complexType which contains complex elements
<complexType name="orderitemstype">
<sequance>
<element
name="quantity" type="itemtype"/>
</sequance>
</complexType>