Defining complexTypes That Mix Data and Elements

Suppose you want to define a complexType that mixes elements and data. For example, you have an XML document with contents such as the following:

<letter>
               

              
<salutation>
                   
Dear Mr.
                   
<name>Robert Smith</name>
                   
,
                   
</salutation>
                   
Your order of 
                   
<quantity>1 </quantity> 
                   
<productName>Baby Monitor </productName> 
                   
shipped from our warehouse on
                   
<shipDate>2001-04-21</shipDate>
                   
. 
                   

                
</letter>

The letter element and salutation element have element and data children. You must define complexTypes for both the letter and the salutation elements. Their Mixed property value must be set to true. The Mixed property is the one that allows an element to contain both elements ( <shipDate>, for example) and raw data ( Dear Mr. for example) as children.

This section describes how to achieve this using both the Diagram and Tree views.

Diagram View

To define a complex type that mixes data and elements:
2. In the Properties window, click the Mixed field.
3. In the drop-down menu that appears, click true.

Tree View

In the Tree view, to define a complex type that mixes data and elements:
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 Properties window, double-click the Mixed field.
5. Double-click true.
6. In the left tool bar, click New Model Group . Stylus Studio displays a pop-up menu that lists the group modifiers.
7. Double-click the modifier you want. For a description of the modifiers, see Model Group Properties in XML Schemas. For the rest of this procedure, assume that you double-click the sequence modifier. By default, the elements that are children of this node each appear exactly once. If you want an element to be optional, or if you want an element to appear more than once, specify appropriate values for the properties for minimum occurrence and maximum occurrence.
8. For each element that you want this complexType to contain:
a. In the left tool bar, click New Element Definition . In the Tree view, Stylus Studio displays a field for the new element definition.
b. Type a name for the new element and press Enter. Stylus Studio displays a pop-up menu that lists the built-in simpleTypes and any types already defined in the schema.
c. Double-click the type for the new element.

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.

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.

Stylus Studio XML Editor Core Functions

Stylus Studio XML Editor Core Functions

EDI to XML Mapping in Stylus Studio

Learn how to use Stylus Studio's EDI to XML mapping tools in Convert-to-XML, including loading an EDI file, inspecting application control codes, customizing XML output and other advanced EDI to XML mapping features.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member