Datasheet

From an XML in databases perspective, DTD could provide a method of structural validation, which is
of course very important to any kind of database structure. However, it could also be superfluous and
simply get in the way. It may depend on how XML documents are created or generated as being sources
of both metadata and data. If XML documents are manually created then something like DTD could be
very useful. Of course, once data is created, it is possible that only one round of validation is required for
at least static data.
Static data in a database is data that does not change very often, if at all. In a database containing customers
and invoices, your customers are relatively static (their names don’t change at least not very often).
Transactional or dynamic data such as invoices is likely to change frequently. However, it is extremely
likely that any creation of XML documents would be automatically generated by application programs.
Why validate with the DTD when applications generating data (XML documents) will do that validation
for you?
The DTD will be covered in a later chapter in detail, where you will deal with schemas and XML
Schemas. XML Schemas are a more advanced form of the DTD. XML Schemas can be used to define
what and how everything is to be created in an XML document.
XML Syntax
The basic syntax rules of XML are simple but also very strict. This section goes through those basic syn-
tax rules one by one:
The XML tag: The first line in an XML document declares the XML version in use:
<?xml version=”1.0”?>
Including style sheets: The optional second line contains a style sheet reference, if a style sheet
is in use:
<?xml:stylesheet type=”text/xsl” href=”cities.xsl”?>
The root node: The next line will contain the root node of the XML document tree structure. The
root node contains all other nodes in the XML document, either directly or indirectly (through
child nodes):
<root>
A single root node: An XML document must have a single root tag, such that all other tags are
contained within that root tag. All subsequent elements must be contained within the root tag,
each nested within its parent tag.
An XML tag is usually called an element.
The ending root tag: The last line will contain the ending element for the root element. All end-
ing elements have exactly the same name as their corresponding starting elements, except that
the name of the node is preceded by a forward slash (/):
</root>
13
What Is XML?
04_791202 ch01.qxp 10/6/06 10:59 AM Page 13