blob: e500f4562e12cb79391efe89e215afb0e3443964 [file] [log] [blame]
syeshin17ed4a62005-07-25 17:10:24 +00001<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE html
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4<html>
5<head>
syeshin15e1cc42005-08-26 04:13:17 +00006<link rel="stylesheet" type="text/css" href="../org.eclipse.wst.doc.user/common.css" />
syeshin17ed4a62005-07-25 17:10:24 +00007<title>Editing a group node</title>
syeshin15e1cc42005-08-26 04:13:17 +00008</head>
syeshin17ed4a62005-07-25 17:10:24 +00009<body id="tedtgnde"><a name="tedtgnde"><!-- --></a>
10
11<h1 class="topictitle1">Editing a group node</h1>
12<div><p>If your element has either element content or mixed content, its
13content model is represented by a group node. You can add children elements
14or another group to a group node, and specify how often, and
15in what manner a group of elements will be available in an XML file associated
16with your DTD.</p><div class="skipspace"><p></p>
17<p>The following instructions were written for the Resource
18perspective, but they will also work in many other perspectives. </p>
19<p>To
20edit a group node, follow these steps:</p>
21</div>
22<ol><li class="skipspace"><span>Open your DTD in the DTD editor.</span></li>
23<li class="skipspace"><span>In the Outline view, expand the tree of the element you want to
24work with.</span></li>
25<li class="skipspace"><span>Click the group node you want to work with.</span></li>
26<li class="skipspace"><span>In the Design view, select <span class="uicontrol">Sequence</span> or <span class="uicontrol">Choice</span> from
27the <span class="uicontrol">Model Group</span> list.</span> This specifies whether
28the group of elements are sorted in sequence or are available as a choice
29in an XML file </li>
30<li class="skipspace"><span>Select the appropriate option from the <span class="uicontrol">Occurrence</span> list
31to indicate how often the group of elements can occur in an XML file associated
32with this DTD. </span></li>
33<li class="skipspace"><span>To add another existing element to a group as a child, right-click
34the group node, click <span class="uicontrol">Add Element to Content Model</span>,
35and specify its name.</span></li>
36<li class="skipspace"><span>You can also add a group to an existing group node, by right-clicking
37the group note and clicking <span class="uicontrol">Add Group to Content Model</span></span></li>
38</ol>
39<div class="skipspace"><p> <b>Note:</b>The <span class="uicontrol">Occurrence</span> option for the
40group node only specifies how often the entire group of elements can occur
41in an XML file. For each child element contained in the group, you can also
42specify how often it can occur (that is, how often a child element can occur
43is completely separate from how the often the group that contains it can occur).</p>
44<p>  <b>Tip:</b>:
45To change the order of elements listed below a group node, simply click the
46element you want to move and drag it to the location you want it in.</p>
47</div>
48<div class="skipspace"><p><b>Creating a group node that contains a list of small pets</b></p>
49<p>The
50following steps show you how to create a group node that contains a list of
51small pets and explains how the choices you select affect how your group node
52(and the elements it contains) can be used in any XML files based on your
53DTD file:</p>
54<ol><li>Create a new DTD called <kbd class="userinput">Pets.dtd</kbd> and open it in
55the DTD editor.</li>
56<li>In the Outline view, right-click your DTD file, and create a new element <kbd class="userinput">SmallPets</kbd>.
57Also create three more elements - <kbd class="userinput">Cats</kbd>,<kbd class="userinput">Dogs</kbd>,
58and.<kbd class="userinput">Fish</kbd></li>
59<li>Expand <span class="uicontrol">SmallPets</span> and select the <span class="uicontrol">EMPTY</span> content
60model.  Select <span class="uicontrol">Mixed Content</span> from the <span class="uicontrol">Content
61type</span> list.  This means your <span class="uicontrol">SmallPets</span> element
62can contain both other elements and character data.</li>
63<li>Your content model is now represented by a group node <img src="../images/XSDChoice.gif" />.
64A #PCDATA element (for character data) and new child element are automatically
65created below it.  Select the <span class="uicontrol">newChild</span> and select
66 <span class="uicontrol">Dogs</span> in the <span class="uicontrol">Name</span> list.</li>
67<li>Right-click the group node and click <span class="uicontrol">Add Element to Content
68Model</span>. Select the new child node and  select <span class="uicontrol">Cats</span> in
69the <span class="uicontrol">Name</span> list.</li>
70<li>Repeat the previous step and select <span class="uicontrol">Fish</span> in the <span class="uicontrol">Name</span> list.</li>
71<li>Now that you have created your list of small pets, you have to decide
72if you want users to be able to select all of them or just one of them in
73an XML file based on this Pets.dtd file. For example, you create a new XML
74file called <kbd class="userinput">Pets.xml</kbd> based on this DTD, and you create
75a <kbd class="userinput">SmallPets</kbd> element in it.  If you selected <span class="uicontrol">Sequence</span> as
76the model group in the DTD file, then you can have all of the small pets ( <span class="uicontrol">Cats</span>,
77 <span class="uicontrol">Dogs</span> and <span class="uicontrol">Fish</span>) in your <span class="uicontrol">SmallPets</span> element
78in the <span class="uicontrol">Pets.xml</span> file. If, however, you selected <span class="uicontrol">Choice</span> as
79the connector type, you can only have one animal listed in your <span class="uicontrol">SmallPets</span> element
80in the <span class="uicontrol">Pets.xml</span> file. You can have <span class="uicontrol">Cats</span> or
81 <span class="uicontrol">Dogs</span> or <span class="uicontrol">Fish</span>, but you can
82only have one at a time.</li>
83<li>Now you have to decide how often this group of elements (the list of small
84pets) can occur in an XML file associated with this DTD.  You can specify
85that it must appear only once ( <span class="uicontrol">Just once</span>), that it
86must appear one or more times ( <span class="uicontrol">One or more</span>), that
87it does not have to appear at all ( <span class="uicontrol">Optional</span>) or that
88it might not be used at all or might be used any number of times ( <span class="uicontrol">Zero
89or more</span>). <span class="uicontrol">Note</span>: You can also specify how
90often each child element can occur. How often a child element can occur is
91completely separate from how the often the group that contains it can occur.
92So, for example, you can specify that the <span class="uicontrol">SmallPets</span> group
93can occur <span class="uicontrol">Just once</span>, but the Cats element can appear
94several times (to do this, select the <span class="uicontrol">Cats</span> element
95and click <span class="uicontrol">One or more</span>).</li>
96<li>The order in which you specify child elements in a group affects how they
97can be used in any instances of the parent element in an XML file. For example,
98if, in your DTD file, you had specified this: <samp class="codeph">&lt;!ELEMENT SmallPets
99(Dogs+ , Cats+ , Fish)+&gt;</samp>, any instances of<span class="uicontrol">SmallPets</span> in
100your <span class="uicontrol">Pets.xml</span> file must contain one or more instances
101of <span class="uicontrol">Dogs</span> followed by one or more instances of <span class="uicontrol">Cats</span>,
102followed by just one occurrence of <span class="uicontrol">Fish</span>. You could
103never 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>
104<li>You can also add a group to an existing group node. Select the node, right-click
105it and click <span class="uicontrol">Add Group to Content Model</span>.  You
106might want to add a group node, if you decided you wanted to sort the animals
107by breed into separate groups.  </li>
108</ol>
109</div>
110</div>
111
112<div>
113<p>
114<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 />
115</p>
116</div><p>
117 (C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.
118</p>
119</body>
120</html>