spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / column10

The Meanings of XML: DTDs, DCDs and Schemas

Oracle Report Developer (IL)
Next Step Systems
US-IL-Elk Grove Village

Justtechjobs.com Post A Job | Post A Resume
Developer News
ActiveState Debuts Open Source Business Suite
Salesforce Offers Visual App Builder
Codesion Steps Out From CVS's Shadow


So far in this column we ignored the more formal aspects of XML, such as defining the correct syntax and semantics of specific documents. While we examined the set of rules common to all documents (remember well-formed vs. valid documents?), I have so far neglected the mechanisms for specifying your own families of documents.

Specification of document syntax

In addition to the general rules every XML document has to adhere to, a Document Type Definition (DTD) or equivalent defines the order and nesting of elements that make up a certain type of XML document such as a purchase order or a news channel. DTDs have their roots in XML's parent SGML and have their own special syntax. Here is a shortened version of the DTD of the Rich Site Summary (RSS) format in use for news channels:

<!ELEMENT rss (channel)>
<!ATTLIST rss
          version     CDATA #REQUIRED> <!-- must be "0.91"> -->

<!ELEMENT channel (title | description | link | language | item+ | ...)*>
<!ELEMENT title (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT link (#PCDATA)>
<!ELEMENT image (title | url | link | width? | height? | description?)*>
<!ELEMENT url (#PCDATA)>
<!ELEMENT item (title | link | description)*>
<!ELEMENT language (#PCDATA)>
<!ELEMENT width (#PCDATA)>
<!ELEMENT height (#PCDATA)>

The full version can be found at MyNetscape.This basically says that a channel is the only element inside an Resource Description Framework (RDF) node and is itself made up of title, description, link and several items in any order, besides other things. These items contain a title, a description, and a link, in any order. DTDs make use of special characters to denote orders of magnitude:

SymbolMeaning
aexactly one a
a?zero or one a's
a+one or more a's
a*zero or more a's
a | ba or b
#PCDATAparsed character data

Using these basic blocks, complex definitions can be formed through nesting of elements, as shown in the RSS DTD above. HTML is also specified in a DTD, and so is XHTML, the reformulation of HTML in XML. You can conceptualize XHTML as an XML vocabulary for expressing screen documents, while RSS is a vocabulary for expressing a collection of links on a certain topic. The more vocabularies the computing industry can agree on, the more we can move on to doing the infrastructure work once and subsequently focus on the business problems at hand that are more important than data decoding and encoding. How many of your Web projects today have to deal with transforming data from one format to another?

http://www.internet.com


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Use Web Caching to Make Your Web Site Faster · Creating an Online Shopping Cart Mechanism in PHP · Log JavaScript Errors Using an AJAX-driven Web Service
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Granular Settings for a Database Level Audit · The Perils of a Web 2.0 Transition on Your Business Processes · Facebook Redesigns Site —Again — Nears 400M Mark

Produced by Michael Claßen
All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/xml/column10/index.html
Created: Mar. 31, 2000
Revised: Mar. 31, 2000