Database Reference
In-Depth Information
Today, XML is used for many purposes. One of the most important is its use as a standard-
ized means to define and communicate documents for processing over the Internet. XML
plays a key role in Microsoft's .NET initiative, and in 2001, Bill Gates called XML the “ lingua
franca of the Internet age.”
We will begin the discussion of XML by describing its use for displaying Web pages. As you
will learn, however, XML uses go far beyond Web page display. In fact, Web page display is one
of the least important applications of XML. We begin with page display only because it is an
easy way to introduce XML documents. After that, we will explain the XML Schema standard
and discuss its use for database processing.
As you read the rest of this chapter, keep in mind that this area is at the leading edge of da-
tabase processing. Standards, products, and product capabilities are frequently changing. You
can keep abreast of these changes by checking the following Web sites: www.w3c.org , www.xml.
org , http://msdn.microsoft.com , www.oracle.com , www.ibm.com , and www.mysql.com . Learning
as much as you can about XML and database processing is one of the best ways you can pre-
pare yourself for a successful career in database processing.
XML as a Markup Language
As a markup language, XML is significantly better than HTML in several ways. For one, XML
provides a clean separation between document structure, content, and materialization. XML
has facilities for dealing with each, and they cannot be confounded, as they are with HTML.
Additionally, XML is standardized, but as its name implies, the standards allow for exten-
sion by developers. With XML, you are not limited to a fixed set of elements such as <title>,
<h1>, and <p>; you can create your own.
Third, XML eliminates the inconsistent tag use that is possible (and popular) with HTML.
For example, consider the following HTML:
<h2>Hello World</h2>
Although the tag can be used to mark a level-two heading in an outline, it can be used for
other purposes, too, such as causing “Hello World” to be displayed in a particular font size,
weight, and color. Because a tag has potentially many uses, we cannot rely on tags to discern
the structure of an HTML page. Tag use is too arbitrary; it may mean a heading, or it may
mean nothing at all.
As you will see, the structure of an XML document can be formally defined. Tags are de-
fined in relationship to one another. In XML, if we find the tag <street>, we know exactly what
data we have, where those data belong in the document, and how that tag relates to other tags.
XML Document Type Declarations
Figure 11-46 shows a sample XML document. Notice that the document has two sections.
The first section defines the structure of the document; it is referred to as the document type
declaration (DTD) . The second part is the document data.
The DTD begins with the word DOCTYPE and specifies the name of this type of docu-
ment, which is Customer . Then, it specifies the content of the Customer document. The
Customer document consists of two groups: CustomerName and Address . The CustomerName
group consists of two elements: FirstName and LastName . FirstName and LastName are de-
fined as #PCDATA, which means that they are strings of character data. Next, the Address ele-
ment is defined to have four elements: Street, City, State , and Zip . Each of these is also defined
as character data. The plus sign (+) after Street indicates that one value is required and that
multiple values are possible.
The data instance of customer shown in Figure 11-46 conforms to the DTD; hence, this
document is said to be a type-valid XML document . If it did not conform to the DTD, it
would be a not-type-valid document . Documents that are not-type-valid can still be perfectly
good XML; they just do not conform to their type description. For example, if the document
in Figure 11-46 had two City elements, it would be valid XML, but it would be not-type-valid.
 
 
Search WWH ::




Custom Search