blob: fdbcdeaf02abae99daa9bbcf2074f8fd69a758e9 [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>
syeshinaaa21932005-09-22 17:13:22 +00006<!-- /*******************************************************************************
7 * Copyright (c) 2000, 2005 IBM Corporation and others.
8 * All rights reserved. This program and the accompanying materials
9 * are made available under the terms of the Eclipse Public License v1.0
10 * which accompanies this distribution, and is available at
11 * http://www.eclipse.org/legal/epl-v10.html
12 *
13 * Contributors:
14 * IBM Corporation - initial API and implementation
15 *******************************************************************************/ -->
16<link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" />
syeshin17ed4a62005-07-25 17:10:24 +000017<title>Creating elements</title>
syeshin15e1cc42005-08-26 04:13:17 +000018</head>
syeshin17ed4a62005-07-25 17:10:24 +000019<body id="tcretelm"><a name="tcretelm"><!-- --></a>
20
21<h1 class="topictitle1">Creating elements</h1>
22<div><p>You can use element declarations in DTDs to define the elements
23that may occur in an XML document. Element declarations can specify that an
24element can contain other elements, that it can contain anything at all, or
25that it must be empty.</p><div class="skipspace"><p>The following instructions were written for the Resource perspective,
26but they will also work in many other perspectives. </p>
27<p><b>Creating
28elements</b></p>
29<p>To create an element, follow these steps:</p>
30</div>
31<ol><li class="skipspace"><span>Open your DTD in the DTD editor.</span></li>
32<li class="skipspace"><span>In the Outline view, right-click the DTD <img src="../images/nDTDFile.gif" alt="Image of the DTD icon" /> and click <span class="uicontrol">Add Element</span>.</span></li>
33<li class="skipspace"><span>In the Properties view, type the new name of the element in the <span class="uicontrol">Name</span> field.</span></li>
34<li class="skipspace"><span>When you create an element in the DTD editor, a child element that
35is EMPTY is automatically created.</span><ol type="a"><li class="skipspace"><span>Select the EMPTY child element and, in the Properties view,
36change its <span class="uicontrol">Content type</span> to ANY, (#PCDATA), or another
37element.</span> If you do not want the parent element to contain anything,
38leave its content model type as EMPTY. </li>
39<li class="skipspace"><span>If you want your parent element to contain more than one child
40element (or mixed content), select <span class="uicontrol">Children Content</span> or <span class="uicontrol">Mixed
41Content</span> from the <span class="uicontrol">Content type</span> list.</span> Once you select either of these, you will have a group (represented
42by a group node - <img src="../images/XSDSequence.gif" /> if you select
43Children Content and <img src="../images/XSDChoice.gif" /> if you select
44Mixed Content), which you can use to create a group of child elements under
45the parent element. A child element will automatically be created under
46the group node. For information on editing a group, refer to the related information.
47 </li>
48</ol>
49</li>
50<li class="skipspace"><span>Click the <span class="uicontrol">Documentation</span> tab
51if you want to provide any information about this element.</span> The <span class="uicontrol">Documentation</span> page
52is used for human readable material, such as a description of the element.</li>
53</ol>
54<div class="skipspace"><p><b>Note</b>: If you intend to have mixed content, the value of
55the first element in your group must be (#PCDATA) (consequently, if you select <span class="uicontrol">Mixed
56Content</span>, two child elements will automatically be created, the
57first one having a value of (#PCDATA)). As well, a group should not contain
58an EMPTY or ANY element. EMPTY or ANY elements are not legally allowed as
59nested entities.</p>
60</div>
61</div>
62
63<div><p><b class="reltaskshd">Related tasks</b><br />
64<a href="../topics/tcretattr.html" title="You can use an attribute to describe an element or provide information about it. Attribute lists enable you to group together all related attributes for an element.">Creating attributes and attribute lists</a><br />
65<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 />
66<a href="../topics/tedtgnde.html" title="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.">Editing a group node</a><br />
67<a href="../topics/tremvelm.html" title="If you have created elements, attributes, entities, notations, and comments you no longer need, you can delete any of them.">Deleting elements, attributes, entities, notations, and comments</a><br />
68</p>
69</div>
syeshin17ed4a62005-07-25 17:10:24 +000070</body>
71</html>