Bookmark this site!

2008-09-20

ENTITY —
(X)HTML entities in XML for XSLT

You can use character entities in your XML provided you declare them.

Add a DOCTYPE to your XML — all you need is the name of your root tag (my document in the example below is a recipe) and a reference to the special character sets you want.

for example

XML-compatible ISO Special Character Entity Set for XHTML

— including lt gt mdash quot euro

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE recipe [
       <!ENTITY % xhtml-special
           PUBLIC "-//W3C//ENTITIES Special for XHTML//EN"
       "http://www.w3.org/MarkUp/DTD/xhtml-special.ent" >
       %xhtml-special;
]>
<recipe>
  ...
</recipe>

other standard character sets

You can add more declarations to the DOCTYPE mdash just add them between the square brackets [...]

XML-compatible ISO Latin 1 Character Entity Set for XHTML

— fractions, accented characters, pound, yen, cent, copy

       <!ENTITY % xhtml-lat1
           PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN"
       "http://www.w3.org/MarkUp/DTD/xhtml-lat1.ent" >
       %xhtml-lat1;

ISO Math, Greek and Symbolic Character Entity Set for XHTML

       <!ENTITY % xhtml-symbol
           PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN"
       "http://www.w3.org/MarkUp/DTD/xhtml-symbol.ent" >
       %xhtml-symbol;

No comments: