Entity Reference versus Character Reference

Not everything that begins with an ampersand is an entity reference. Entity references are only used for named entities, including the five predefined entity references such as < and any entities defined with ENTITY declarations in the DTD such as &chapter1; in the example above.

By contrast, character references use a hexadecimal or decimal Unicode value, not a name , to refer to a particular character. Each always refers to a single character, never to a group of characters . For example,   is a hexa decimal character reference referring to the nonbreaking space character, and   is a decimal character reference referring to that same character. XHTML's   is an entity reference referring to that character.

Almost always, even APIs that faithfully report all entity references do not report character references. Instead, the parser silently merges the referenced characters into the surrounding text. Your code should never depend on whether a character was typed literally or escaped with a character reference. Almost all the time, it shouldn't depend on whether the character was escaped with an entity reference either.



Effective XML. 50 Specific Ways to Improve Your XML
Effective XML: 50 Specific Ways to Improve Your XML
ISBN: 0321150406
EAN: 2147483647
Year: 2002
Pages: 144

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net