Information Technology Reference
In-Depth Information
Here, the XML processor has no di culty in disambiguating different member
tags, since they are all uniquely qualified by namespaces; for unprefixed tags
and attributes, the default namespace http://www.wsmo.org/namespace is
used, whereas the prefix math is used to point to the namespace http://www.
example.org/mathstuff/sets/ .
We can see from this simple example that namespaces and unique identifi-
cation are crucial underpinnings for combining and exchanging XML data in
a Web context or in other open environments where the partner is not known
upfront.
As a side remark, note that namespace declarations are an example where
URIs are used not only to identify Web-accessible documents, but also as
abstract resources.
2.3.2 XML Schema
DTDs impose several restrictions with respect to expressivity. This means
that only very simple languages can be defined by means of DTDs alone. For
instance, one cannot define restrictions on how often a certain element may
appear by only regular expressions; moreover, datatypes are hardly supported;
etc.
These limitations are overcome by another mechanism for defining XML
grammars, XML Schema. Beyond DTDs, XML schema allows advanced fea-
tures such as the following:
support for a basic set of datatypes (numbers, strings, and dates, etc.),
which can be restricted further;
definition of one's own element or attribute types, available for reuse via
an inheritance mechanism which allows extension/restriction;
namespace support;
XML Schema is an XML language itself, allowing developers to profit from
tool support, the inherent extensibility of XML, the combination of several
XML Schema files, etc.
Listing 2.4 shows a schema for the XML file shown in Listing 2.1, which
exposes some of these features. For instance, it specifies a common type
namestring , which is based on the basic XML Schema string datatype re-
stricted to strings starting with an upper-case letter. This type is assigned
to both the firstname and the lastname elements. In order to derefer-
ence the schema in Listing 2.4, the DTD reference in Listing 2.1 would
need to be replaced with a reference to the XML Schema document. For
more details of XML Schema we refer to the XML Schema Standard, see
http://www.w3.org/XML/Schema .
Note, however, that XML Schema still operates on a purely syntactic level
in defining the structure of XML data and, more importantly, there are certain
things that are beyond the expressivity of XML Schema. These shortcomings
will be partly resolved by technologies to be discussed in Chapter 3:
Search WWH ::




Custom Search