Defining complexTypes That Contain Elements and Attributes - Tree View

The purchaseOrder.xsd sample document contains the following complexType definition. This complexType defines three elements, refers to a fourth element, and defines an attribute.

<xsd:complexType name="PurchaseOrderType"> 
               

              
<xsd:sequence> 
                   
<xsd:element name="shipTo" type="USAddress"/> 
                   
<xsd:element name="billTo" type="USAddress"/> 
                   
<xsd:element ref="comment" minOccurs="0"/> 
                   
<xsd:element name="items" type="Items"/> 
                   
</xsd:sequence> 
                   
<xsd:attribute name="orderDate" type="xsd:date"/> 
                   

                
</xsd:complexType>

In the Tree view, to define a complex type with a similar structure:
1. Click the Schema node.
2. In the left tool bar, click New complexType . In the Tree view, Stylus Studio displays a field for the new complexType.
3. Type a name for this new complexType and press Enter.
4. In the left tool bar, click New Model Group . Stylus Studio displays a pop-up menu that lists the group modifiers.
5. Double-click the modifier you want. For a description of each modifier, see Model Group Properties in XML Schemas.

You can specify any number of modifiers in a complexType. Each modifier controls the occurrence of its child nodes. You can specify the same modifier more than once. For example, you might want to specify the sequence modifier, with some child nodes, then the choice modifier with some child nodes, and then the sequence modifier again with other child nodes.

6. For each element that you want to define in this complexType with the selected modifier, perform the following steps:
a. Click the modifier name in the Tree view.
b. In the left tool bar, click New Element Definition . In the Tree view, Stylus Studio displays a field for the new element definition.
c. Type a name for the new element and press Enter. Stylus Studio displays a pop-up menu that lists the built-in simpleTypes and simpleTypes you defined.
d. Double-click the type for the new element.
e. In the Properties window, you can double-click the field for any property to set the value for that property.

For example, you can specify 0 for the Min Occur. property and 1 for the Max property. The effect is that the element is optional.

7. For each element or group that you want to refer to in this complexType with the selected modifier, perform the following steps:
a. Click the modifier name in the Tree view.
b. In the left tool bar, click New Reference to Element or New Reference to Group . Stylus Studio displays a pop-up menu that lists the elements or groups defined in the schema.
c. Double-click the element or group you want to reference.
8. To define an attribute in this complexType:
a. Click the name of the complexType in the Tree view.
b. In the left tool bar, click New Attribute . In the Tree view, Stylus Studio displays a field for the new attribute.
c. Type a name for the new attribute and press Enter. Stylus Studio displays a pop-up menu that lists the built-in simpleTypes and the simpleTypes you defined in this schema.
d. Double-click the type of the new attribute.
9. To reference an attribute or attributeGroup in this complexType:
a. Click the name of the complexType in the Tree view.
b. In the left tool bar, click New Reference to Attribute or New Reference to Attribute Group . Stylus Studio displays a pop-up menu that lists the attributes or attributeGroups defined in the schema.
c. Double-click the attribute or attributeGroup you want to reference.

XML Validator

Stylus Studio has a built-in XML validator that supports industry-standard DTD and XML Schema validators including MSXML 4.0 SAX, MSXML 4.0 DOM, Microsoft .NET XML Parser (System.XML), Xerces-J 2.5.1, XSV 2.6, etc. Validate XML with Stylus Studio.

An Introduction to XQuery Development

An Introduction to XQuery demonstrates how easy it is to use Stylus Studio's many tools for editing, testing and deploying XQuery applications. Learn how to write your first XQuery application in just minutes by watching this online tutorial.

DTD Editor

The Stylus Studio DTD Editor lets you visually develop Document Type Definitions (DTD) to structure XML documents. The DTD Editor also includes tools and utilites for validating XML against DTD's, converting DTD's, and generating DTD's.

Stylus Studio Enables Multi-Channel Publishing for University of Pittsburg Professor

Learn how Dr. David Birnbaum of the University of Pittsburgh uses Stylus Studio to develop customized XSLT stylesheets that produce enhanced versions of source documents in different output formats, including Web and print.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member