Вы находитесь на странице: 1из 4

Jelord

March 12, 2015

Rey

Gulle

Web Services [IT 182]

a.) Definitions:
XML DTD
DTD or Document Type Definition. This defines the elements that
may be included in your document, what attributes these elements
have, and the ordering and nesting of the elements.
XML Schema
XML Schemas provide a much more powerful means by which to
define your XML document structure and limitations. XML Schemas are
themselves XML documents. They reference the XML Schema
Namespace, and even have their own DTD.
What XML Schemas do is provide an Object Oriented approach to
defining the format of an XML document. XML Schemas provide a set
of basic types. These types are much wider ranging than the
basic PCDATA and CDATA of DTDs. They include most basic
programming types such as integer, byte, string and floating point
numbers, but they also expand into Internet data types such as ISO
country and language codes (en-GB for example).

b.) Difference
The DTD provides a basic grammar for defining an XML
Document in terms of the metadata that comprise the shape of the
document. An XML Schema provides this, plus a detailed way to define
what the data can and cannot contain. It provides far more control for
the developer over what is legal, and it provides an Object Oriented
approach, with all the benefits this entails.
Firstly, and rather an important point, is that XML Schema is a
new technology. This means that whilst some XML Parsers support it
fully, many still dont. If you use XML to communicate with a legacy
system, perhaps it wont support the XML Schema.
Many systems interfaces are already defined as a DTD. They are
mature definitions, rich and complex. The effort in re-writing the
definition may not be worthwhile.

DTD is also established, and examples of common objects


defined in a DTD abound on the Internet freely available for re-use.
A developer may be able to use these to define a DTD more quickly
than they would be able to accomplish a complete re-development of
the core elements as a new schema.
Finally, you must also consider the fact that the XML Schema is
an XML document. It has an XML Namespace to refer to, and an XML
DTD to define it. This is all overhead. When a parser examines the
document, it may have to link this all in, interoperate the DTD for the
Schema, load the namespace, and validate the schema, etc., all before
it can parse the actual XML document in question. If youre using XML
as a protocol between two systems that are in heavy use, and need a
quick response, then this overhead may seriously degrade
performance.
c.) Uses
XML DTD
XML provides an application independent way of sharing data.
With a DTD, independent groups of people can agree to use a common
DTD for interchanging data. Your application can use a standard DTD to
verify that data that you receive from the outside world is valid. You
can also use a DTD to verify your own data.
XML Schema
XML schema is used to provide a list of elements and attributes
in a vocabulary; to associate types, such as integer, string, etc., or
more specifically such as hatsize, sock_colour, etc., with values found
in documents; to constrain where elements and attributes can appear,
and what can appear inside those elements, such as saying that a
chapter title occurs inside a chapter, and that a chapter must consist
of a chapter title followed by one or more paragraphs of text; to
provide documentation that is both human-readable and machineprocessable; to give a formal description of one or more documents.

d.) Examples
XML DTD

XML Schema

Вам также может понравиться