UIEvolutin Inc.
UJML Language Reference
XML Entities

XML entities are symbols that are converted to other values when the XML file is interpreted.

Note: This is a quick introduction to XML entities. You should also search the Internet for more information and/or read some of the many excellent books on the subject. 

Entities are special symbols that XML converts to other values when the XML file is interpreted. The format of an entity is an ampersand ('&') followed by the symbol name, followed by a semicolon (';'). For example, '&' is an entity for the ampersand (&) character. 

One use of entities is to allow you to enter text into your XML document which would otherwise be interpreted as XML markup. For example, the '\&lt;' entity inserts a literal '<' into a document. So the string '<box>' may be represented in an XML document as '\&lt;box>'. 

Another use of entities is the character reference, which allows you to enter arbitrary characters into your XML document, including characters which cannot be typed directly on your keyboard. This is done by entering an ampersand, followed by a pound symbol ('#'), followed by the Unicode character code point, followed by a semicolon. For example, '&#8478;'. The numeric reference value may be decimal ('&#8478;') or hexadecimal ('&#x211E;').

Entity declarations

You can define your own custom entities and use them in your XML document. Entities are declared in a Document Type Definition (DTD), which is either a separate file or a DOCTYPE directive at the top of your XML document. 

Entities are defined with a left angle bracket ('<'), followed by a bang ('!'), followed by the word 'ENTITY' (in upper case), followed by a space (' '), followed by the entity symbol (no spaces are allowed in the symbol, although underlines may be substituted), followed by another space, followed by the entity value inside of single or double quotes, followed by a closing right angle bracket ('>'). For example, the entity declaration '<!ENTITY SALUTATION "Hello World!">' creates the '&SALUTATION;' entity which, if used in an XML file, is replaced with 'Hello World!' when the XML file is interpreted.

Custom entity declarations

Custom entity declarations are handy for things like constant values, where you only want to enter the actual value once and refer to it with a symbol elsewhere. This is very helpful if the value might change and you are using it in many places throughout the document. An entity may also contain XML markup, so you may use an entity to incorporate small snippets of XML markup into your XML file using just a symbol. The XML markup in an entity may contain other entities, which are themselves interpreted, so you can build combinations of entities. 

You may create custom entity declarations in the DOCTYPE directive of your UJML file or in a separate 'include' file. See Entity Include Files.

Predefined entities provided by UJML

UJML provides a rich set of predefined entities you can use in your UJML code. See Entities.

Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
What do you think about this topic? Send feedback!