eWebProgrammer eweb  





XML Programming  «Prev  Next»
Lesson 1

Creating XML documents

Well-formedness is the quality of a linguistic element that conforms to the grammar of the language of which it is a part. Well-formed words or phrases are grammatical, meaning they obey all relevant rules of grammar.
When you create XML documents, you must work within two constraints:
  1. well-formedness
  2. and validity.

This module explains the well-formedess rules and how they are applied to create well-formed XML documents. The validity constraint is defined in this module and the technical details of creating valid XML documents will be discussed later in the course.

Module learning objectives

By the end of the module, you will have the skills and knowledge necessary to:
  1. Describe the concepts of well-formedness and validity
  2. List the rules for creating a well-formed XML document
  3. Determine the inherent structure of information within XML documents
  4. Create a well-formed XML document
  5. Work with mixed content
  6. Add clarity and information to XML documents using comments, CDATA sections, and encoding
The next lesson describes the concepts of well-formedness and validity.


Defining Namespaces

At their simplest, namespaces are a way of grouping elements and attributes under a common heading in order to differentiate them from similarly-named items. Take the following scenario: You overhear two people talking and one says to the other, “You need a new table.”
Question : What does that mean? There could be quite a number of options depending on the context.
For example it could be:
  1. Someone discussing a dinner party with their spouse and they need a bigger dining table.
  2. A database developer who has been asked to design a system to store user preferences on a website, a new database table.
  3. An HTML developer who has been told to display some extra information on the user’s account page, an HTML table.
You can tell only if you know the context, or if the complete names are used, dining table, database table, or HTML table. This is how namespaces work with elements and attributes. You can group these items under a namespace so that they keep their familiar name, such as user, but also have a namespace so that they can be differentiated, both by a human reader and a software application, from any other elements that may be called user by someone else.