blob: 20ac729516673615321d7caa47b0493d8a15a279 [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>Reusing internal parameter entities in an attribute name or type</title>
</head>
<body id="trusintp"><a name="trusintp"><!-- --></a>
<h1 class="topictitle1">Reusing internal parameter entities in an attribute name or type</h1>
<div><p>Reusing parameter entities in attributes can save you a lot of
time. If you have several elements using the exact same attribute, you only
have to input the information once (into an entity).  </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>You
can create a DTD that reuses internal parameter entities in attributes. To
reuse internal parameter entities in attributes, follow these steps:</p>
</div>
<ol><li class="skipspace"><span>In the workbench, create a new DTD.</span></li>
<li class="skipspace"><span>Add a new entity to the DTD you just created.</span></li>
<li class="skipspace"><span>Select <span class="uicontrol">Parameter</span> from the <span class="uicontrol">Entity
type</span> list, and type a value in the <span class="uicontrol">Entity Value</span> field.</span></li>
<li class="skipspace"><span>Create an element and add an attribute to it. </span></li>
<li class="skipspace"><span>If you want to reuse the entity in an attribute name, in the <span class="uicontrol">Name</span> field
for the attribute, type the name of the entity (that is, %NewEntity;) then
in the <span class="uicontrol">Type</span> field, select the type for the attribute.</span> <b>Tip</b>: If you want to use an entity to replace an entire attribute
definition, select <span class="uicontrol">(none)</span> from the <span class="uicontrol">Type</span> list.</li>
<li class="skipspace"><span>If you want to reuse the entity as the type of an attribute, type
the name of the attribute, and, in the <span class="uicontrol">Type</span> field,
click the name of the entity you created in step 2.</span></li>
<li class="skipspace"><span>Repeat steps 4 and 5 or 4 and 6 as applicable.</span></li>
</ol>
<div class="skipspace">You now have two attributes with the same name or type.</div>
<div class="skipspace"><p> The following sample shows how you might reuse internal parameter
entities in an attribute type.</p>
<p>You are making a list of office supplies,
and all your supplies have Part and Stock attributes.</p>
<ol><li>Create a new DTD called <kbd class="userinput">OfficeSupplies.dtd</kbd> .</li>
<li>Add an entity called <kbd class="userinput">PartStock</kbd>. Select <span class="uicontrol">Parameter</span> from
the <span class="uicontrol">Entity type</span> list. In the <span class="uicontrol">Entity Value</span> field,
type <kbd class="userinput">Part ID #REQUIRED Stock CDATA #IMPLIED</kbd>.</li>
<li>Add three new elements to OfficeSupplies.dtd: <kbd class="userinput">pen</kbd>, <kbd class="userinput">paper</kbd>,
and <kbd class="userinput">pencils</kbd>. Make the value of each element <span class="uicontrol">(#PCDATA)</span>.</li>
<li>Right-click <span class="uicontrol">pen</span> and click <span class="uicontrol">Add Attribute</span>.
In the <span class="uicontrol">Name</span> field for the attribute, type <kbd class="userinput">ID_Numbers</kbd>.
In the <span class="uicontrol">Type</span> field, click <span class="uicontrol"> %PartStock;</span>.</li>
<li>Repeat step 4 for <span class="uicontrol">paper</span> and <span class="uicontrol">pencils.</span></li>
</ol>
<p>You now have three elements with the same attribute. </p>
</div>
</div>
<div>
<p>
<b class="parentlink">Parent topic:</b> <a href="../topics/tcretent.html" title="An entity is a shortcut used to represent complex strings or symbols that would otherwise be impossible, difficult or repetitive to include by hand.">Creating entities</a><br />
</p>
<p><b class="reltaskshd">Related tasks</b><br />
<a href="../topics/trusents.html" title="Reusing the value of an entity in another entity can save you time in several ways. For example, if your value is long and complicated, it is much faster to simply reuse an entity than manually type in your value each time. As well, if the value changes, you only have to change it in one location.">Reusing the value of one entity in another entity</a><br />
<a href="../topics/trusextp.html" title="Using an entity in a content model can save you time if you want to have the same information in several content models. You can create a DTD that references another DTD and then declares an element whose content model refers to a parameter entity created in another DTD.">Reusing external parameter entities in an element's content model</a><br />
</p>
</div>
</body>
</html>