Abbett.org

Using HTML entities in your XML document

In a Clickframes appspec, I write a lot of content that will be displayed, ultimately, as HTML. Frequently, that content will include dashes, spaces, and other typographic symbols that are common in HTML, but require explicit declarations in plain XML.

Here's the simplest way to include those entity definitions.

After your XML declaration...

<?xml version="1.0" encoding="UTF-8"?>

...include the following DOCTYPE declaration...

<!DOCTYPE appspec [
    <!ENTITY % HTMLlat1 PUBLIC
       "-//W3C//ENTITIES Latin 1 for XHTML//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
    <!ENTITY % HTMLspec PUBLIC
        "-//W3C//ENTITIES Special for XHTML//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
    %HTMLlat1;
    %HTMLspec;
]>

Replace appspec with the name of the root element of your document.

Update: Make sure you don't use standalone="yes" in your XML declaration.

 

1 comments

Update: Make sure you don't use standalone="yes" in your XML declaration.
 

Add a comment

Please add a comment using your Twitter account. Don't have one? Sign up.