| <?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> |
| <link rel="stylesheet" type="text/css" href="../org.eclipse.wst.doc.user/common.css" /> |
| <title>Creating entities</title> |
| </head> |
| <body id="tcretent"><a name="tcretent"><!-- --></a> |
| |
| <h1 class="topictitle1">Creating entities</h1> |
| <div><p>An entity is a shortcut used to represent complex strings or symbols |
| that would otherwise be impossible, difficult or repetitive to include by |
| hand. </p><div class="skipspace"><p>For example, you need to place a copyright notification (for example, <var class="varname">Copyright |
| 2005. MyCompany publishing</var>.) at the end of every page of a book. |
| Instead of writing it every time, you could create an entity that represents |
| this text: <samp class="codeph"><!ENTITY copyright "Copyright 2005. MyCompany publishing."></samp> where <samp class="codeph">copyright</samp> is |
| the name of the entity and <samp class="codeph">"Copyright 2004. MyCompany publishing"</samp> is |
| the text that the <samp class="codeph">copyright</samp> entity represents.</p> |
| <p>To create |
| an entity, 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, right-click the DTD <img src="../images/nDTDFile.gif" alt="Image of the DTD icon" /> and click <span class="uicontrol">Add Entity </span>.</span></li> |
| <li class="skipspace"><span>In the Properties view, type the new name of the entity in the <span class="uicontrol">Name</span> field.</span></li> |
| <li class="skipspace"><span>From the <span class="uicontrol">Entity Type</span> list, select <span class="uicontrol">General</span> or <span class="uicontrol">Parameter</span>. </span> General entities are used in XML files, whereas parameter entities are |
| used only in the DTD and do not have any use in an XML file.</li> |
| <li class="skipspace"><span>Select the <span class="uicontrol">External</span> check box if you |
| want to declare your entity as an external entity. An external entity references |
| an external document or data.</span></li> |
| <li class="skipspace"><span>If you did make the entity external, the following fields appear:</span><ul><li><span class="uicontrol">Public ID</span> (Optional). Type the path of the |
| DTD you want to reference. You can then use the resources in the file you |
| are referencing.</li> |
| <li><span class="uicontrol">System ID</span>. Type the path of the external data |
| or document you want to reference, or browse for it. You can then use the |
| resources in the file you are referencing.</li> |
| </ul> |
| <p>You only need to specify the <span class="uicontrol">Public ID</span> or |
| the <span class="uicontrol">System ID</span>, not both. If, in your DTD, you want |
| to use any of the resources (such as elements or attributes) contained in |
| the document you have referenced, you must make this entity a <span class="uicontrol">Parameter</span> entity, |
| and "expand" the entity by creating an external parameter entity reference |
| (right-click the DTD <img src="../images/nDTDFile.gif" alt="Image of the DTD icon" />, |
| click <span class="uicontrol">Add Parameter Entity Reference</span>, and select the |
| entity you just created). </p> |
| </li> |
| <li class="skipspace"><span>If you did not make the entity external, you can specify the entity |
| value in the <span class="uicontrol">Entity value</span> field. </span></li> |
| <li class="skipspace"><span>Click the <span class="uicontrol">Documentation</span> tab if you want |
| to provide any information about this entity.</span> The <span class="uicontrol">Documentation</span> page |
| is used for human readable material, such as a description of the entity.</li> |
| </ol> |
| <div class="skipspace">The follow links explain different ways you can reuse entities:</div> |
| </div> |
| |
| <div> |
| <blockquote> |
| <div class="ulchildlink"><b><a href="../topics/trusintp.html">Reusing internal parameter entities in an attribute name or type</a></b><br /> |
| 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). </div> |
| <div class="ulchildlink"><b><a href="../topics/trusents.html">Reusing the value of one entity in another entity</a></b><br /> |
| 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.</div> |
| <div class="ulchildlink"><b><a href="../topics/trusextp.html">Reusing external parameter entities in an element's content model</a></b><br /> |
| 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.</div> |
| </blockquote> |
| |
| <p> |
| <b class="parentlink">Parent topic:</b> <a href="../topics/tedtdtd.html" title="You can edit DTD files in both the Outline view and the Source view. Modifying the content of a DTD determines what can be used in any XML file that is associated with it.">Editing DTDs</a><br /> |
| </p> |
| <p><b class="reltaskshd">Related tasks</b><br /> |
| <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 /> |
| </p> |
| </div><p> |
| (C) Copyright IBM Corporation 2000, 2005. All Rights Reserved. |
| </p> |
| </body> |
| </html> |