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