blob: 9f9d6fa98e523ba4950ba1f206326874831c3840 [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">
<!-- /*******************************************************************************
* 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
*******************************************************************************/ -->
<html>
<head>
<link rel="stylesheet" type="text/css" href="../org.eclipse.wst.doc.user/common.css" />
<title>Editing an element's content model</title>
</head>
<body id="tchgelm"><a name="tchgelm"><!-- --></a>
<h1 class="topictitle1">Editing an element's content model</h1>
<div><p>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.</p><div class="skipspace"><p>There are four kinds of content models: <i>element content</i>,
<i>mixed content</i>, <i>EMPTY content</i> and <i>ANY content</i></p>
<p>In
the <i>element content</i> content model an element can only contain other
child elements. In the <i>mixed content</i> content model, an element can
contain both character data (text that is not parsed by the XML parser) and
other child elements. In the <i>EMPTY content</i> content model, an element
cannot contain any other elements or text. In the <i>ANY content</i> content
model, the element can literally contain anything - other elements, in any
number, and text.</p>
<p>In the DTD editor, you can create elements with any
of these content models. When you create an element in the DTD editor, a child
element with an EMPTY content model is automatically created.</p>
<p>The following
instructions were written for the Resource perspective, but they will also
work in many other perspectives. </p>
<p>To edit an element's content
model, 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 parent element you want to work
with.</span></li>
<li class="skipspace"><span>Select the first child of the expanded parent element.</span> This
is the element's content model.</li>
<li class="skipspace"><span>In the Design view, you change its <span class="uicontrol">Content type</span> to</span><ul><li><span class="uicontrol">ANY</span></li>
<li>(#PCDATA)</li>
<li>Another element</li>
<li><span class="uicontrol">Children Content</span> or <span class="uicontrol">Mixed Content</span>.</li>
</ul>
Once you select either <span class="uicontrol">Children Content</span> or <span class="uicontrol">Mixed
Content</span> you will have a group (represented by a group node - <img src="../images/XSDSequence.gif" /> if you select <span class="uicontrol">Children Content</span> and <img src="../images/XSDChoice.gif" /> if you select <span class="uicontrol">Mixed Content</span>),
which you can use to create a group of child elements under the parent element.
A child element will automatically be created under the group node. For information
on editing a group, refer to the related information.<p><b>Note</b>: If you
intend to have mixed content, the value of the first element in your group
must be (#PCDATA) (consequently, if you select <span class="uicontrol">Mixed Content</span>,
two child elements will automatically be created, the first one having a value
of (#PCDATA).</p>
</li>
<li class="skipspace"><span>If you do not want the parent element to contain anything, leave
its <span class="uicontrol">Content type</span> as <span class="uicontrol">EMPTY</span>.</span></li>
<li class="skipspace"><span>Select the appropriate <b>Occurrence</b> option to indicate how
often the element can occur in an XML file.</span> This option is not
available if you select ANY, (#PCDATA), EMPTY, or another element.</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>To add a group to the content model, right-click the group node
and click <span class="uicontrol">Add Group to Content Model</span>.</span> For
information on editing a group, refer to the link below.</li>
</ol>
<div class="skipspace"></div>
</div>
<div>
<blockquote>
<div class="ulchildlink"><b><a href="../topics/tedtgnde.html">Editing a group node</a></b><br />
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.</div>
</blockquote>
<p>
<b class="parentlink">Parent topic:</b> <a href="../topics/tcretelm.html" title="You can use element declarations in DTDs to define the elements that may occur in an XML document. Element declarations can specify that an element can contain other elements, that it can contain anything at all, or that it must be empty.">Creating elements</a><br />
</p>
</div>
</body>
</html>