Criteria for Well-Formed XML Documents

[Previous] [Next]

To be well formed, your XML document must meet the following requirements:

  1. The document must contain a single root element.
  2. Every element must be correctly nested.
  3. Each attribute can have only one value.
  4. All attribute values must be enclosed in double quotation marks or single quotation marks.
  5. Elements must have begin and end tags, unless they are empty elements.
  6. Empty elements are denoted by a single tag ending with a slash (/).
  7. Isolated markup characters are not allowed in content. The special characters <, &, and > are represented as &gt, &amp, &lt in content sections.
  8. A double quotation mark is represented as &quot, and a single quotation mark is represented as &apos in content sections.
  9. The sequence <[[ and ]]> cannot be used.
  10. If a document does not have a DTD, the values for all attributes must be of type CDATA by default.

Rules 1 through 6 have been addressed in this chapter. If you need to use the special characters listed in rules 7 and 8, be sure to use the appropriate replacement characters. The sequence in rule 9 has a special meaning in XML and so cannot be used in content sections and names. We will discuss this sequence in Chapter 5. The CDATA type referred to in rule 10 consists of any allowable characters. In our sample document, the values for the attributes must contain characters, which they do.



Developing XML Solutions
Developing XML Solutions (DV-MPS General)
ISBN: 0735607966
EAN: 2147483647
Year: 2000
Pages: 115
Authors: Jake Sturm

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net