Specifying That an Element Can Contain One or More Elements in DTDs

Often, you want an element to contain a sequence of elements. Some of these elements might be required, some might be optional, and some might be able to occur more than once. There might even be a group of elements in which only one can appear.

In the Tree tab, to define an element that contains a sequence of elements:
1. Define the elements that you want your new element to contain. See Defining Elements in DTDs.
2. Define the element that contains the sequence of elements. This is the container element.
3. Click the container element name.
4. In the left tool bar, click New Modifier . Stylus Studio displays a drop-down menu.
5. Double-click Sequence.
6. To add required elements to the container element, click New Reference to Element in the left tool bar and enter the name of the required element. Do this for each required element. You can change the order later.

At this point, you can add

  • Optional elements
  • Elements that can appear one or more times
  • Elements that can appear zero, one, or more times
  • Elements that belong to a group in which only one element in the group can be present
Specifying Modifiers

The procedure is the same for these modifiers. The only difference is the modifier you select. For example, following are the instructions for adding optional elements:

1. In the DTD editor, click the Sequence modifier.
2. In the left tool bar, click New Modifier.
3. Double-click Optional.
4. For each optional element, click New Reference to Element and enter the name of the optional element. This works only if you want all optional elements to be consecutive. If you want optional elements to be interspersed with required elements or elements that can appear one or more times, you must perform steps 1 through 4 for each element.
Modifying the Order

In an instance document, the contained elements must appear in the order in which they are specified in the DTD.

To modify the order:
1. Click the modifier for the element you want to move.
2. Click the up or down arrow repeatedly until the element is where you want it to be.

To move a required element that can appear only once, click its name and then use the up and down arrows.

Alternative: Right-click the item you want to move. Select Move Up or Move Down from the shortcut menu.

XSV - The XML Schema Validator

XSV is the official reference implementation for the XML Schema language and Stylus Studio is the only XML IDE to provide seamless integration with XSV - the W3C XML Schema Validator. Download Stylus Studio and XSV today.

Web Service Data-to-XML Mapper

Stylus Studio provides a powerful standards-based solution for accessing and transforming live Web service XML data. Intuitive tools like the Web Service Call Composer and UDDI Browser make developing Web service applications a snap.

Using DataDirect XML Converters

Learn how to use DataDirect XML Converters and the Stylus Studio Java Code Generator to deploy the XQuery applications you build in Stylus Studio to a live server environment.

DTD vs. Schema

Stylus Studio provides tools for working with both W3C XML Schema and DTD's - this tutorial explains what the differences are between the two, providing a technical comparison of DTD vs Schema.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member