When defining XSD you can either choose to define your types as nested types or global types (complexType).
I understand that global types are of much more use when it comes to morphism or reusing of elements.
However, if you have a big data model you would have to define for each level a global complexType and then create an element that references the global type.
Nested
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname"/>
<xs:element name="lastname"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="street"/>
<xs:element name="city"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
Global
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="nameType"/>
<xs:element name="address" type="addressType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="nameType">
<xs:sequence>
<xs:element name="firstname"/>
<xs:element name="lastname"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addressType">
<xs:sequence>
<xs:element name="street"/>
<xs:element name="city"/>
</xs:sequence>
</xs:complexType>
Hence, my question: When are you using nested types instead of making them global?
For anyone interested: My question somehow relates to this question (XML attribute vs element).