Creating Documents  «Prev  Next»

Lesson 5 Working with mixed content
ObjectiveCreate a well-formed document from text.

XML Mixed Content Application

XML elements can include a combination of data and other elements.
In the book catalog example, the XML file was structured such that every individual element either contained other elements, such as
  1. <BOOK> and
  2. <TITLE>, or
  3. data,
such as a name or an ISBN number.
This is referred to as the mixed content model.
There are situations where the use of the mixed content model is desirable. For example, if you are translating a business letter into an XML document, you may use the mixed content model so that certain parts of the letter are in XML and other parts are in plain text. Note that you may also avoid using the mixed content model by creating additional XML elements. The mechanics of creating mixed content XML elements will be discussed later in the course.
View the XML diagram below to examine what happens when you mix more text with the information from the book catalog.
Mixing more text with the information from the book catalog
Mixing more text with the information from the book catalog

This XML document is considerably different in terms of the look and the intermingling of text with tags and text inside the BOOK element. Yet this still meets the rules for well-formedness and would be considered an XML document. A mixed complex type element can contain attributes, elements, and text.
The next lesson shows you how to add clarity and information to XML documents.