Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Internal Versus External DTDs

May 3, 1999

As we have already alluded to several times throughout this tutorial, a DTD can either be included as part of a well-formed XML document, (standalone=yes), or it can be referenced from an external source, (standalone=no).

The benefits of using external DTDs is that they can more easily and efficiently be shared by more than one XML document, or in fact, many organizations with the need to standardize communications and data. You can write a DTD once and have multiple documents reference it. Not only does this save typing time, but it assures that as the DTD manager makes changes to the central DTD, all documents that rely on the DTD are updated in one fell swoop. (Of course, DTD changes will not necessarily be backwards compatible, so watch out!).

In order to reference an external DTD, you must change both the XML declaration and the DOCTYPE declaration.

The XML Declaration must be changed to reflect the fact that the XML document will not work on its own. That is, it will not be standalone.

<?xml version = "1.0" 
         encoding="UTF-8" 
         standalone = "no"?>

You will also need to change the DOCTYPE declaration to add the SYSTEM attribute.

<!DOCTYPE ROOT_ELEMENT 
     SYSTEM "URL_OF_EXTERNAL_DTD">

such as....

<!DOCTYPE CONTACTS 
     SYSTEM "http://www.mydomain.com/dtds/contacts.dtd">

Note also, that the URL may be a relative or absolute file location such as....

<!DOCTYPE CONTACTS 
     SYSTEM "contacts.dtd">

which specifies a dtd file in the same directory as the XML document that references it. Or, similarly, you can reference the same document up one directory and down one into the "dtds" directory using something like the following.

<!DOCTYPE CONTACTS 
     SYSTEM "../dtds/contacts.dtd">

Using this method, you can simply cut out the DTD from your XML document and paste it into the separate document called contacts.dtd. Thus, you have one file with the DTD and one file with the well-formed XML document.

Entity Declarations
Introduction to XML For Web Developers | Table of Contents
Public DTDs


Up to => Home / Authoring / Languages / XML / Tutorials / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers