Home >Online Product Documentation >Table of Contents >Defining complexTypes That Contain Elements and Attributes - Diagram View
schema node
Alternatives: This operation is also available from the XMLSchema > Diagram > Add > ComplexType menu and from the Add button
.
The new complexType is added to the XML Schema. It is displayed in the diagram and in the text pane (if you have it open). The properties for the new complexType are displayed in the Properties window.
Once you have created a complexType, you can further define it by adding sequences, elements, and other nodes. The basic procedure for adding nodes to a complexType is to:
You can use this procedure to add the following nodes to a complexType:
Next steps vary according to the constraints on the elements in the complexType. The following instructions show how to achieve some typical constraints.
Suppose you want to define a complexType that contains exactly one element, and that element can be one of several different elements. In XML Schema, you do this by defining xsd:choice.
Alternatives: This operation is also available from the XMLSchema > Diagram > Add > Choice menu and from the Add button
.
Stylus Studio displays the choice icon
alongside the complexType icon.
choice icon and select Add > Element, or use the Add button
A element is added to the choice icon.
Suppose you want to define a complexType that contains a number of elements, the elements can be in any order, and there must be zero or one of each element. In XML Schema, you do this by defining xsd:all.
Alternatives: This operation is also available from the XMLSchema > Diagram > Add > All menu and from the Add button
.
Stylus Studio displays the all icon
alongside the complexType icon.
choice icon and select Add > Element, or use the Add button
A element is added to the all icon.
Suppose you want to define a complexType that contains a number of elements in a particular order. The default is that each element must appear exactly once. However, some elements are optional, and some elements can appear more than once. In XML Schema, you do this by defining xsd:sequence.
Alternatives: This operation is also available from the XMLSchema > Diagram > Add > Sequence menu and from the Add button
.
Stylus Studio displays the sequence icon
alongside the complexType icon.
sequence icon and select Add > Element, or use the Add button
A element is added to the sequence icon.
If you make a mistake in the order in which you specify nodes in your XML Schema (when specifying elements in a sequence, for example), you can rearrange them.
Alternative: This operation is also available from the XMLSchema menu and from the node's shortcut menu.
Suppose you want to define a complexType that contains a number of elements in a particular order, but some of them are optional, and you want to ensure that only one element from a particular group of elements is present. In other words, you need to combine the use of the sequence and choice modifiers. To define this, you must define a sequence modifier first. You can then define sequence and choice modifiers that are children of the initial sequence modifier.