|
Home >Online Product Documentation >Table of Contents >Defining a complexType in a Sample XML Schema in the Diagram View Defining a complexType in a Sample XML Schema in the Diagram ViewThis topic is part of a sequence that begins with Description of Sample XML Schema.
The steps for defining the Defining the Name of a Sample complexType in the Diagram ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. To define a complexType in a sample XML Schema:
1. From the Stylus Studio menu bar, select File > New > XML Schema.
Stylus Studio displays the XML Schema Editor. Maximize the XML Schema Editor window. If the Project window is visible, you can close it.
2. At the bottom of the XML Schema editor, click the Diagram tab.
Stylus Studio displays the Diagram view for the new schema.
3. Right-click the schema node in the XML Schema diagram pane and select Add > ComplexType from the shortcut menu.
Alternatives: This action is also available from the XMLSchema > Grid Editing menu.
Stylus Studio displays a representation for the new node in the diagram. The complexType properties appear in the Properties window. The new complexType has a default name of
4. Type PublicationType in the Name property in the Properties window and press Enter.
Stylus Studio updates the diagram and the XML Schema in the text pane.
5. Click Save
.
6. In the Save As dialog box, in the URL field, type bookstoreDiagram.xsd , and click Save. You can save it in the examples directory of the Stylus Studio installation directory or in a directory of your choice.
Adding an Attribute to a Sample complexType in the Diagram ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. To add the genre attribute to the PublicationType complexType:
1. Right-click the PublicationType node.
2. In the shortcut menu that appears, select Add > Attribute.
Stylus Studio displays a node for the new attribute (
3. In the Properties window, type genre as the name of the new attribute and press Enter.
4. In the Properties window, click the Type field.
Stylus Studio displays a drop-down list of built-in types.
5. Scroll down to xsd:string and click it, or type xsd:string and press Enter.
The diagram should now look like the one shown in Figure 69 .
6. Click Save
.
Adding Elements to a Sample complexType in the Diagram ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. The elements belonging to this complexType must occur in a specific order. Before defining the first element, you need to create a sequence node to define this requirement in the XML Schema. To add the title element to the PublicationType complexType:
1. Right-click the PublicationType node.
2. In the shortcut menu that appears, select Add > Sequence.
The
3. Type title and press Enter.
4. Right-click the sequence node
.
5. In the shortcut menu that appears, select Add > Element.
A child element is added to the
6. In the Properties window, click the Name field and enter title .
7. In the Properties window, click the Type field.
Stylus Studio displays a drop-down list of built-in types.
8. Scroll down to xsd:string and click it, or type xsd:string and press Enter.
According to the XML Schema requirements described earlier, the Adding Optional Elements to a Sample complexType in the Diagram ViewThis topic is part of a sequence that begins with Description of Sample XML Schema. To add the optional subtitle element to the PublicationType complexType:
1. Right-click the sequence node
.
2. In the shortcut menu that appears, select Add > Element.
Below the
3. Rename the new element subtitle .
4. Give the new element a data type of xsd:string .
5. Give the new element a minimum occurrences value of 0.
You can accept the default of
6. Click Save
.
At this point, the XML Schema diagram should look like Figure 70: Adding an Element That Contains Subelements to a complexType in the Diagram ViewThis topic is part of a sequence that begins with Description of Sample XML Schema.
The sample schema requirements (see Description of Sample XML Schema) state that the
Each element that can contain one or more subelements is a complexType. Consequently, to add the To define the AuthorType complexType:
1. Right-click the schema node in the XML Schema diagram pane and select Add > ComplexType from the shortcut menu.
Alternatives: This action is also available from the XMLSchema > Grid Editing menu. Stylus Studio displays a representation for the new node in the diagram. The complexType properties appear in the Properties window.
2. Type AuthorType in the Name property in the Properties window and press Enter.
Stylus Studio updates the diagram and the XML Schema in the text pane.
3. Right-click the AuthorType node in the diagram.
4. In the shortcut menu that appears, select Add > Sequence.
Stylus Studio displays the
5. Right-click the sequence node.
6. In the shortcut menu that appears, select Add > Element.
7. Type first-name in the Name property in the Properties window and press Enter.
8. Change the Type property to xsd:string and press Enter.
9. Repeat step 5 through step 8 to add a new element to the sequence, using last-name as the name of the new element.
Now you can add the author element to the PublicationType complexType:
1. Right-click the sequence node belonging to the PublicationType node.
2. In the shortcut menu that appears, select Add > Element.
Stylus Studio displays a representation for the new node in the diagram. The complexType properties appear in the Properties window.
3. Type author in the Name property in the Properties window and press Enter.
Stylus Studio updates the diagram and the XML Schema in the text pane.
4. Click the Type field in the Properties window. Stylus Studio displays a drop-down list of built-in types plus any types you have defined, such as the AuthorType you defined in the previous procedure.
5. Select AuthorType from the drop-down list.
6. Click the Max Occur. field.
7. In the drop-down list that appears, click unbounded.
8. Click Save
.
At this point, the XML Schema diagram should look like Figure 71: Choosing the Element to Include in a Sample complexType in the Diagram 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. Right-click the sequence node belonging to the PublicationType node.
2. In the shortcut menu that appears, select Add > Sqeuence.
Stylus Studio displays a representation for the new
We added the
3. Right-click the new sequence node. In the shortcut menu that appears, select QuickEdit > Switch to Choice.
Stylus Studio changes the
4. Right-click the new choice node.
5. In the shortcut menu that appears, select Add > Element.
6. In the Properties window, change the Name to ISBNnumber and press Enter.
7. In the Properties window, change the Type xsd:int and press Enter.
8. Repeat step 4 through step 7 twice: once to add the PUBnumber element, and once to add the LOCnumber element.
9. Click Save
.
The definition of the |