blob: 6a85f7c24c3d0f9fd95a1907fa50164717160ea6 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<!-- /*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/ -->
<link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" />
<title>Editing a group node</title>
</head>
<body id="tedtgnde"><a name="tedtgnde"><!-- --></a>
<h1 class="topictitle1">Editing a group node</h1>
<div><p>If your element has either element content or mixed content, its
content model is represented by a group node. You can add children elements
or another group to a group node, and specify how often, and
in what manner a group of elements will be available in an XML file associated
with your DTD.</p><div class="skipspace"><p></p>
<p>The following instructions were written for the Resource
perspective, but they will also work in many other perspectives. </p>
<p>To
edit a group node, follow these steps:</p>
</div>
<ol><li class="skipspace"><span>Open your DTD in the DTD editor.</span></li>
<li class="skipspace"><span>In the Outline view, expand the tree of the element you want to
work with.</span></li>
<li class="skipspace"><span>Click the group node you want to work with.</span></li>
<li class="skipspace"><span>In the Design view, select <span class="uicontrol">Sequence</span> or <span class="uicontrol">Choice</span> from
the <span class="uicontrol">Model Group</span> list.</span> This specifies whether
the group of elements are sorted in sequence or are available as a choice
in an XML file </li>
<li class="skipspace"><span>Select the appropriate option from the <span class="uicontrol">Occurrence</span> list
to indicate how often the group of elements can occur in an XML file associated
with this DTD. </span></li>
<li class="skipspace"><span>To add another existing element to a group as a child, right-click
the group node, click <span class="uicontrol">Add Element to Content Model</span>,
and specify its name.</span></li>
<li class="skipspace"><span>You can also add a group to an existing group node, by right-clicking
the group note and clicking <span class="uicontrol">Add Group to Content Model</span></span></li>
</ol>
<div class="skipspace"><p> <b>Note:</b>The <span class="uicontrol">Occurrence</span> 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).</p>
<p>  <b>Tip:</b>:
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.</p>
</div>
<div class="skipspace"><p><b>Creating a group node that contains a list of small pets</b></p>
<p>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 your group node
(and the elements it contains) can be used in any XML files based on your
DTD file:</p>
<ol><li>Create a new DTD called <kbd class="userinput">Pets.dtd</kbd> and open it in
the DTD editor.</li>
<li>In the Outline view, right-click your DTD file, and create a new element <kbd class="userinput">SmallPets</kbd>.
Also create three more elements - <kbd class="userinput">Cats</kbd>,<kbd class="userinput">Dogs</kbd>,
and.<kbd class="userinput">Fish</kbd></li>
<li>Expand <span class="uicontrol">SmallPets</span> and select the <span class="uicontrol">EMPTY</span> content
model.  Select <span class="uicontrol">Mixed Content</span> from the <span class="uicontrol">Content
type</span> list.  This means your <span class="uicontrol">SmallPets</span> element
can contain both other elements and character data.</li>
<li>Your content model is now represented by a group node <img src="../images/XSDChoice.gif" />.
A #PCDATA element (for character data) and new child element are automatically
created below it.  Select the <span class="uicontrol">newChild</span> and select
<span class="uicontrol">Dogs</span> in the <span class="uicontrol">Name</span> list.</li>
<li>Right-click the group node and click <span class="uicontrol">Add Element to Content
Model</span>. Select the new child node and  select <span class="uicontrol">Cats</span> in
the <span class="uicontrol">Name</span> list.</li>
<li>Repeat the previous step and select <span class="uicontrol">Fish</span> in the <span class="uicontrol">Name</span> list.</li>
<li>Now that you have created your 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 <kbd class="userinput">Pets.xml</kbd> based on this DTD, and you create
a <kbd class="userinput">SmallPets</kbd> element in it.  If you selected <span class="uicontrol">Sequence</span> as
the model group in the DTD file, then you can have all of the small pets ( <span class="uicontrol">Cats</span>,
<span class="uicontrol">Dogs</span> and <span class="uicontrol">Fish</span>) in your <span class="uicontrol">SmallPets</span> element
in the <span class="uicontrol">Pets.xml</span> file. If, however, you selected <span class="uicontrol">Choice</span> as
the connector type, you can only have one animal listed in your <span class="uicontrol">SmallPets</span> element
in the <span class="uicontrol">Pets.xml</span> file. You can have <span class="uicontrol">Cats</span> or
<span class="uicontrol">Dogs</span> or <span class="uicontrol">Fish</span>, but you can
only have one at a time.</li>
<li>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 ( <span class="uicontrol">Just once</span>), that it
must appear one or more times ( <span class="uicontrol">One or more</span>), that
it does not have to appear at all ( <span class="uicontrol">Optional</span>) or that
it might not be used at all or might be used any number of times ( <span class="uicontrol">Zero
or more</span>). <span class="uicontrol">Note</span>: 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 <span class="uicontrol">SmallPets</span> group
can occur <span class="uicontrol">Just once</span>, but the Cats element can appear
several times (to do this, select the <span class="uicontrol">Cats</span> element
and click <span class="uicontrol">One or more</span>).</li>
<li>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, in your DTD file, you had specified this: <samp class="codeph">&lt;!ELEMENT SmallPets
(Dogs+ , Cats+ , Fish)+&gt;</samp>, any instances of<span class="uicontrol">SmallPets</span> in
your <span class="uicontrol">Pets.xml</span> file must contain one or more instances
of <span class="uicontrol">Dogs</span> followed by one or more instances of <span class="uicontrol">Cats</span>,
followed by just one occurrence of <span class="uicontrol">Fish</span>. You could
never have an occurrence of <span class="uicontrol">Fish</span> after <span class="uicontrol">Dogs</span> or <span class="uicontrol">Cats</span> before <span class="uicontrol">Dogs</span>. </li>
<li>You can also add a group to an existing group node. Select the node, right-click
it and click <span class="uicontrol">Add Group to Content Model</span>.  You
might want to add a group node, if you decided you wanted to sort the animals
by breed into separate groups.  </li>
</ol>
</div>
</div>
<div>
<p>
<b class="parentlink">Parent topic:</b> <a href="../topics/tchgelm.html" title="An element's content model represents any data that can 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). Editing an element's content model enables you to determine exactly what the element can (and cannot) contain.">Editing an element's content model</a><br />
</p>
</div>
</body>
</html>