You have defined the content of the Address element. Now you need to define the content of the Person element. The Person element is to contain the following child elements, all of which are simple types: First, Last, Title, PhoneExt, and Email. All these elements are mandatory except Title (which is optional), and they must occur in the order just specified. All should be of datatype xs:string except PhoneExt, which must be of datatype xs:integer and limited to 2 digits.
To create the content model for Person:
|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 value 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.|
Making an element optional
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:
|1.||Double-click in the type field of the PhoneExt element, and select (or enter) the xs:integer entry from the dropdown list.|
The items in the Facets Entry Helper change at this point.
|2.||In the Facets Entry Helper, double-click in the maxIncl field and enter 99. Confirm with Enter.|
This defines that all phone extensions up to, and including 99, are valid.
|3.||Select the menu option File | Save to save the changes to the schema.|
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 C:\Documents and Settings\<username>\My Documents\Altova\XMLSpy2019\Examples\Tutorial folder of your XMLSpy application folder.|
© 2019 Altova GmbH