|
Home >Online Product Documentation >Table of Contents >Defining a complexType in a Sample XML Schema in the Tree View Defining a complexType in a Sample XML Schema in the Tree ViewThis topic is part of a sequence that begins with Description of Sample XML Schema.
The steps for defining the Defining the Name of the Sample complexType in the Tree ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. To define a complex type in the sample XML Schema:
1. From the Stylus Studio menu bar, select File > New > XML Schema.
Stylus Studio displays the XML Schema Editor.
2. At the bottom of the XML Schema Editor, click the Tree tab.
Stylus Studio displays the Tree view of the schema, and the Properties window, which lists the properties for the selected node in the tree.
3. Click the Schema node
.
4. In the left tool bar, click New complexType
.
Stylus Studio displays a field for the new complexType.
5. Type PublicationType as the name for this new complexType and press Enter.
6. Click Save
.
7. In the Save dialog box that appears, in the URL field, type bookstoreTree.xsd , and click Save.
Adding an Attribute to a Sample complexType in the Tree ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. To add the genre attribute to the PublicationType complex type:
1. In the Tree view, click the PublicationType node.
2. In the left tool bar, click New Attribute Definition
.
In the Tree view, Stylus Studio displays a field for the new attribute.
3. Type genre as the name of the new attribute and press Enter.
Stylus Studio displays a drop-down list of built-in simpleTypes.
4. Double-click xsd:string.
Adding Elements to a Sample complexType in the Tree ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. To add the title element, which must appear exactly once, to the PublicationType complex type:
1. In the Tree view, click the PublicationType node.
2. In the left tool bar, click New Model Group
.
Stylus Studio displays a drop-down list of group modifiers.
3. Double-click the sequence modifier.
The
4. In the left tool bar, click New Element Definition
.
In the Tree view, Stylus Studio displays a field for the new element definition.
5. Type title as the name of the new element and press Enter.
Stylus Studio displays a drop-down list of built-in simpleTypes.
6. Double-click xsd:string.
Adding Optional Elements to a Sample complexType in the Tree ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. To add the optional subtitle element to the PublicationType complex type:
1. In the Tree view, click the sequence node.
2. In the left tool bar, click New Element Definition
.
In the Tree view, Stylus Studio displays a field for the new element definition.
3. Type subtitle as the name of the new element and press Enter.
Stylus Studio displays a drop-down list of built-in simpleTypes.
4. Double-click xsd:string.
5. In the Properties window, double-click the Min Occur. field.
6. Type 0 and press Enter
7. In the Properties window, double-click the Max Occur. field.
8. Type 1 and press Enter.
Adding an Element That Contains Subelements to a complexType in the Tree ViewThis topic is part of a sequence that begins with Description of Sample XML Schema.
The
Each element that can contain subelements is a complexType. Consequently, to add the To define the authorType complex type:
1. In the XML Schema Editor, click the Schema node.
2. In the left tool bar, click New complexType
.
Stylus Studio displays a field for the new complexType.
3. Type authorType as the name for this new complexType and press Enter.
4. In the left tool bar, click New Model Group
.
5. In the drop-down list that appears, double-click the sequence modifier.
6. In the left tool bar, click New Element Definition
.
7. In the field that Stylus Studio displays, type first-name as the name of the new element and press Enter.
8. In the drop-down list that appears, double-click xsd:string.
9. In the Tree view, click the sequence modifier for authorType .
Now you can add the author element to the PublicationType complex type:
1. In the Tree view, click the sequence node under the PublicationType node.
2. In the left tool bar, click New Element Definition
.
3. In the field that Stylus Studio displays, type author as the name of the new element and press Enter.
4. In the drop-down list that appears, double-click authorType.
5. In the Properties window, double-click in the Min Occur. field.
6. Type 1 and press Enter.
7. In the Properties window, double-click in the Max Occur. field.
8. Type unbounded in the Max Occur. field and press Enter.
Choosing the Element to Include in the Sample complexType in the Tree ViewThis topic is part of a sequence that begins with Description of Sample XML Schema.
In the sample XML Schema, you want To specify this:
1. In the Tree view, under the PublicationType node, click the sequence node.
2. In the left tool bar, click New Model Group
.
3. In the drop-down list that appears, double-click the choice modifier.
4. In the left tool bar, click New Element Definition
.
5. In the field that Stylus Studio displays, type ISBNnumber as the name of the new element and press Enter.
6. In the drop-down list that appears, scroll until you can double-click xsd:integer, or type xsd:integer and press Enter.
7. In the Tree view, click the choice modifier for PublicationType .
8. Repeat step 4 through step 7 two more times. Once for the PUBnumber element and once for the LOCnumber element.
9. Click Save
.
Stylus Studio displays a message that indicates that the schema is not valid. Click OK in the error box. In the Output Window, you can see the following message:
The problem is that there is a
10. Right-click the genre node.
11. In the pop-up menu that appears, click Move Down.
12. Click Validate Document
and Save .
The definition of the |