This is the mail archive of the docbook@lists.oasis-open.org mailing list for the DocBook project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: XML Schemas and docbook documents


At 4:19 PM -0800 11/15/01, Earl Bingham wrote:

>Since I have heard that all new standards with W3 and since .NET is 
>completely XML Schema related, is DTD's dead?


No, no, no, a thousands times NO! DTDs are not dead and they are not 
going away.  This is a common myth with little basis in reality. 
Schemas cannot do everything DTDs do, including some things that are 
crucial for DocBook like entity declarations.

DTDs were designed for exactly the sort of applications that Docbook 
is, and they fit the needs of this technology very well. Schemas were 
designed for different sorts of application of which DocBook isn't 
one. If you'll indulge me while I quote myself (XML Bible, Gold 
Edition, Chapter 23, 
<http://www.ibiblio.org/xml/books/biblegold/chapters/ch24.html>):

Document Type Definitions (DTDs) are an outgrowth of XML's heritage 
in the Standardized General Markup Language (SGML). SGML was always 
intended for narrative-style documents: books, reports, technical 
manuals, brochures, Web pages, and the like. DTDs were designed to 
serve the needs of these sorts of documents, and indeed they serve 
them very well. DTDs let you state very simply and straightforwardly 
that every book must have one or more authors, that every song has 
exactly one title, that every PERSON element has an ID attribute, and 
so forth. Indeed for narrative documents that are intended for human 
beings to read from start to finish, that are more or less composed 
of words in a row, there's really no need for anything beyond a DTD. 
However, XML has gone well beyond the uses envisioned for SGML. XML 
is being used for object serialization, stock trading, remote 
procedure calls, vector graphics, and many more things that look 
nothing like traditional narrative documents; and it is in these new 
arenas that DTDs are showing some limits.

The limitation most developers notice first is the almost complete 
lack of data typing, especially for element content. DTDs can't say 
that a PRICE element must contain a number, much less a number that's 
greater than zero with two decimal digits of precision and a dollar 
sign. There's no way to say that a MONTH element must be an integer 
between 1 and 12. There's no way to indicate that a TITLE must 
contain between 1 and 255 characters. None of these are particularly 
important things to do for the narrative documents SGML was aimed at; 
but they're very common things to want to do with data formats 
intended for computer-to-computer exchange of information rather than 
computer-to-human communication. Humans are very good at handling 
fuzzy systems where expected data is missing, or perhaps in not quite 
the right format; computers are not. Computers need to know that when 
they expect an element to contain an integer between 1 and 12, the 
element really contains an integer in that range and nothing else.

...

However, schemas are not a be-all and end-all solution. In 
particular, schemas do not replace DTDs! You can use both schemas and 
DTDs in the same document. DTDs can do several things that schemas 
cannot do, most importantly declaring entities. And of course, DTDs 
still work very well for the classic sort of narrative documents they 
were originally designed for. Indeed, for these types of documents, a 
DTD is often considerably easier to write than an equivalent schema. 
Parsers and other software will continue to support DTDs for as long 
as they support XML.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+

----------------------------------------------------------------
To subscribe or unsubscribe from this elist use the subscription
manager: <http://lists.oasis-open.org/ob/adm.pl>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]