Datasheet
numbers are discarded and only the names of continents and countries are returned. It is almost
as if the XML document might as well look like that shown next, with all population numbers
removed. The result in Figure 1-7 will still be exactly the same:
<?xml version=”1.0”?>
<?xml:stylesheet type=”text/xsl” href=”791202 fig0107.xsl” ?>
<populationInThousands>
<world>
<continents>
<continent name=”Africa”>
<countries>
<country name=”Burundi”></country>
<country name=”Comoros”></country>
</countries>
...
</continent>
</continents>
</world>
</populationInThousands>
Attributes
Elements can have attributes. An element is allowed to have zero or more attributes that describe it.
Attributes are often used when the attribute is not part of the textual data set of an XML document,
or when not using attributes is simply awkward. Store data as individual elements and metadata as
attributes.
Metadata is the data about the data. In a database environment the data is the names of your customers and
the invoices you send them. The metadata is the tables you define which are used to store records in cus-
tomer and invoice tables. In the case of XML and HTML metadata is the tags or elements (
< . . . > . . .
< . . . >) contained within a web page. The values between the tags is the actual data.
Once again, the now familiar population example:
<populationInThousands>
<world>
<continents>
<continent name=”Africa” year1998=”748,927” year2025=”1,298,311”
year2050=”1,766,082”>
<countries>
<country name=”Burundi”>
<year1998>6457</year1998>
<year2025>11569</year2025>
<year2050>15571</year2050>
</country>
19
What Is XML?
04_791202 ch01.qxp 10/6/06 10:59 AM Page 19