Bookmark this site!


(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"
       "" >

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"
       "" >

ISO Math, Greek and Symbolic Character Entity Set for XHTML

       <!ENTITY % xhtml-symbol
           PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN"
       "" >

No comments: