Embedding Non-XML Data in a Document

In the previous example, I associated an image, image.gif, with a document, but only by setting an attribute to the text "image.gif". What if I wanted to make image.gif a real part of the document?

I can do that by treating image.gif as an external unparsed entity. The creators of XML realized that XML was not ideal for storing data that is not text. So, they added the idea of unparsed entities as a way of associating non-XML data, such as non-XML text, or binary data, with XML documents.

To declare an external unparsed entity, you use an <!ENTITY> element like this. Note the keyword NDATA, indicating that I'm referring to an unparsed entity:

<!ENTITY NAME SYSTEM VALUE NDATA TYPE> 

Here, NAME is the name ...

Get Real World XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.