You have defined the content of the Address element. Now you need to define the content of the Person element, which must contain the following simpleType child elements: First, Last, Title, PhoneExt, and Email. All these elements must be mandatory, except Title, and they must occur in the order just specified. All should be of type xs:string except PhoneExt, which must be of type xs:integer and limited to two digits.
To create the content model for Person, do the following:
1.Right-click the Person element to open the context menu, and select Add Child | Sequence. This inserts the Sequence compositor.
2.Right-click the Sequence compositor, and select Add Child | Element.
3.Enter First as the name of the element, and press the Tab key. This automatically places the cursor in the type field.
4.Select the xs:string entry from the dropdown list or enter it into the Type field.
5.Use the drag-and-drop method to create four more elements. Name them Last, Title, PhoneExt, and Email, respectively.
Note: | You can select multiple elements by holding down the Ctrl key and clicking each of the required elements. This makes it possible to, e.g., copy several elements at once. |
Right-click the Title element and select Optional from the context menu. The frame of the element box changes from solid to dashed; this is a visual indication that an element is optional.
In the Details Entry Helper, you will see that minOcc=0 and maxOcc=1, indicating that the element is optional. Alternatively to using the context menu to make an element optional, you can set minOcc=0 in order to make the element optional.
To define the PhoneExt element to be of type xs:integer and have a maximum of two digits, do the following:
1.Double-click in the type field of the PhoneExt element, and select (or enter) the xs:integer entry from the dropdown list (see screenshot below).
2.The items in the Facets entry helper change at this point. In the Facets entry helper, double-click in the maxIncl field and enter 99. Confirm with Enter. This specifies that phone extensions can have values from 0 to 99.
3.Select File | Save to save the schema changes.
Note the following
•Selecting an XML Schema datatype that is a simple type (for example, xs:string or xs:date) automatically changes the content model to simple in the Details entry helper (content = simple).
•Adding a compositor to an element (sequence, choice, or all), automatically changes the content model to complex in the Details entry helper (content = complex).
•The schema described above is available as AddressFirst.xsd in the Tutorial folder of your XMLSpy application folder.