Editing a group

 

+
Search Tips   |   Advanced Search

 

An element's content model is the representation of any data that may be contained inside an element. It represents any data that may be contained inside or within the content of an element (that is, between the start and end tags of an element in an XML file).

If you select to have an element content or mixed content model, the content model will automatically be represented by a group node. You can add child elements to this group node and specify information about the children grouped below the group node. For more information on content models, refer to the related information.

The following instructions were written for the XML perspective, but they will also work in many other perspectives.

To edit a group node,...

  1. Open the DTD in the DTD editor.

  2. In the Outline view, expand the tree of the element you want to work with.

  3. Click the group node you want to work with.

  4. In the Design view, select Sequence or Choice from the Model Group drop down list. This specifies whether the group of elements are sorted in sequence or are available as a choice.

  5. Select the appropriate option from the Occurrence drop down list to indicate how often the group of elements can occur in an XML file associated with this DTD.

  6. To add another existing element to a group as a child, right-click the group node, click Add Element to Content Model, and specify its name.

  7. You can also add a group to an existing group node, by right-clicking the group note and clicking Add Group to Content Model

The Occurrence option for the group node only specifies how often the entire group of elements can occur in an XML file. For each child element contained in the group, you can also specify how often it can occur (that is, how often a child element can occur is completely separate from how the often the group that contains it can occur).

To change the order of elements listed below a group node, simply click the element you want to move and drag it to the location you want it in.

 

 

Creating a group node that contains a list of small pets

The following steps show you how to create a group node that contains a list of small pets and explains how the choices you select affect how the group node (and the elements it contains) can be used in any XML files based on the DTD file:

  1. Create a new DTD called Pets.dtd and open it in the DTD editor.

  2. In the Outline view, right-click the DTD file, and create a new element SmallPets. Also create three more elements - Cats,Dogs, and.Fish

  3. Expand SmallPets and select the EMPTY content model. Select Mixed Content from the Content type list. This means the SmallPets element can contain both other elements and character data.

  4. Your content model is now represented by a group node

    . A #PCDATA element (for character data) and new child element are automatically created below it. Select the newChild and select Dogs in the Name drop down list.

  5. Right-click the group node and click Add Element to Content Model. Select the new child node and select Cats in the Name drop down list.

  6. Repeat the previous step and select Fish in the Name drop down list.

  7. Now that you have created the list of small pets, you have to decide if you want users to be able to select all of them or just one of them in an XML file based on this Pets.dtd file. For example, you create a new XML file called Pets.xml based on this DTD, and you create a SmallPets element in it. If you selected Sequence as the model group in the DTD file, then you can have all of the small pets ( Cats, Dogs and Fish) in the SmallPets element in the Pets.xml file. If, however, you selected Choice as the connector type, you can only have one animal listed in the SmallPets element in the Pets.xml file. You can have Cats or Dogs or Fish, but you can only have one at a time.

  8. Now you have to decide how often this group of elements (the list of small pets) can occur in an XML file associated with this DTD. You can specify that it must appear only once ( Just once), that it must appear one or more times ( One or more), that it does not have to appear at all ( Optional) or that it may not be used at all or may be used any number of times ( Zero or more). Note: You can also specify how often each child element can occur. How often a child element can occur is completely separate from how the often the group that contains it can occur. So, for example, you can specify that the SmallPets group can occur Just once, but the Cats element can appear several times (to do this, select the Cats element and click One or more).

  9. The order in which you specify child elements in a group affects how they can be used in any instances of the parent element in an XML file. For example, if you had specified the following in the DTD file: <!ELEMENT SmallPets (Dogs+ , Cats+ , Fish)+>, any instances ofSmallPets in the Pets.xml file must contain one or more instances of Dogs followed by one or more instances of Cats, followed by just one occurrence of Fish. You could never have an occurrence of Fish after Dogs or Cats before Dogs.

  10. You can also add a group to an existing group node. Select the node, right-click it and click Add Group to Content Model. You might want to add a group node, if you decided you wanted to sort the animals by breed into separate groups.

 

Parent topic

Editing an element's content model

 

Related tasks

Creating elements