Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

From the author of

Referencing External Entities

ENTITY attributes are provided to allow XML documents to include references to data that is not valid XML, and possibly not even textual. The basic usage of an entity attribute is to declare an external unparsed entity using an <!ENTITY> declaration (covered in the next section), and then use the entity name as the value for an entity attribute. One common application of this feature is to include image data in an XML document, as shown in Listing 1.

Listing 1[em]Entity Attribute Example

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE picture [
 <!NOTATION gif SYSTEM "images/gif">
 <!ENTITY flowers_gif SYSTEM "flowers.gif" NDATA gif>
 <!ELEMENT picture EMPTY>
 <!ATTLIST picture

<picture src="flowers_gif"/>

Although this approach has some advantages, such as associating notation information with external entity references, many XML experts recommend against using entity attributes for this purpose. More familiar and full-featured solutions such as the XLink standard should be used instead.

  • + Share This
  • 🔖 Save To Your Account