XML

Summary

Although the code for many XML documents is somewhat self-explanatory, there are situations where it can be beneficial to provide additional information about XML code using comments or even temporarily disable XML code with comments. This tutorial showed you how to use comments, which allow you to make your code easier to understand. In addition to comments, you also learned how characters of text are encoded in an XML document. Although you might never change the character encoding scheme of your documents from the default setting, it is nonetheless important to understand why there are different encoding options.

After learning about comments and character encoding schemes, you spent the bulk of this tutorial getting acquainted with entities. You found out about parsed entities and unparsed entities, as well as the difference between internal and external entities. From there you learned the significance of notations and how they affect unparsed entities. Finally, the tutorial concluded with a practical XML application that allowed you to create an online radio driven by an XML document.

Q&A

Q.

How exactly are parsed entities merged with document content?

A.

You can think of the merger of parsed entities with document content as a search-and-replace operation. For example, if you had a certain word in a word processor document that you wanted to replace with a phrase, you would perform a search-and-replace, which replaces each occurrence of the word with the phrase. Parsed entities work in a very similar manner, except that the word is the entity reference and the phrase is the entity data; an XML processor carries out the search-and-replace process.

Q.

Why is it necessary to use notations for familiar binary data types such as GIF and JPEG images?

A.

GIF and JPEG images are "familiar" only within the context of a web browser, which is inherently associated with HTML. XML is a much broader technology that doesn't necessarily have a direct tie with a web browser. Therefore, no partiality is given to web data types over any other data types. XML's approach is to require notations for all binary entities.

Q.

Why would I ever want to place text in an external entity?

A.

Although any text could be included directly in an XML document as an internal entity, any large pieces of text that are shared among several documents would benefit greatly from being placed in external files. The storage of these entities would then be isolated in one place, and they could simply be referenced by each document.