O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required