|An entity references in xml is a symbolic representation of information.
What does that mean?
Well, let’s imagine for a moment that we wanted to create an introduction that is included in every single letter that we write. It would be monotonous to have to type out a three sentence introduction for every letter, but not to worry, XML entities can help us out.
|With symbolic representation of information, a lot of text, such as, “Best view resolution 800 x 600” can be represented by an entity symbol such as &view;|
|The format of an entity in XML is an ampersand(&), followed by the name of the symbol, and concluded with a semicolon.|
|• Generic Entity – &name;|
|HTML is another markup language that supports entities. Below are some example entities and the information they represent.|
|•© = ©
• < = <
• gt; = >
• ® =®
|Creating an XML Entity|
|An entity must be created in the Document Type Definition (DTD). When you know where to place the entity, the rest is easy. Here is the syntax for creating your own XML entities.|
|<!ENTITY entityName “The text to appear when the entity is used”>|
|Below we have created an entity for the default introduction we want to include on all of our documents.|
|<!ENTITY copy ” Copyright 2016 www.csitquestions.com All Rights Reserved””>|
|After the entity has been created in the DTD it can then be referenced. An example email XML document that uses such an entity would look like:|
|<!ENTITY copy ” Copyright 2016 www.csitquestions.com All Rights Reserved”> <associate_details>
<associate type=”silver”>Dharmendra Das </associate>
|Entities are great for many situations. Especially if we… use something a lot. If we have a default introduction, signature, or something else that is commonly used, you should use an entity. change something often. If we have a relatively static document that has one or two pieces of information, that are used throughout the document, that change frequently replace them with entities. You only need to change the value of the entity to change hundreds or maybe even thousands of references that are in your XML document. are using complex ascii characters that don’t occur on your keyboard: © and ®are easy when you use entities.|