
Chapter 18 Working with XML
Complex type
In XML-Schema, a complex type allows elements in its content and may carry attributes. Complex types can be:
- Global, that is to say defined as a child of the schema element, in order to be reused among schema elements. You design a global complex type using a class with the <<complexType>> stereotype. In the following example, UsAddress is a complex type with a set of attributes that specify it:
<xsd:complexType name="UsAddress">
<xsd:element name="name" type="Name"/>
<xsd:element name="street" type="string"/>
<xsd:element name="town" type="string"/>
<xsd:element name="zip" type="Integer"/>
</xsd:complexType>
- Local to an element definition. In this case, you have to create a class with the <<element>> stereotype. You then need to set the isComplexType extended attribute of the class to True. This is to make sure that attributes defined in the <<element>> class are generated as a complex type:
<xsd:element name="customer">
<xsd:complexType>
<xsd:element name="name" type="int"/>
<xsd:element name="address" type="int"/>
</xsd:complexType>
</xsd:element>
Copyright (C) 2006. Sybase Inc. All rights reserved.
|
|