Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


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
International

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


Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

Generating a DTD the Easy Way

April 12, 1999

Remember I said not to worry about the fact that we hadn't given any thought to a DTD? Fortunately, there is an online service called DTDGenerator FrontEnd that will generate a DTD for you from your XML instance! It's incredibly easy to use and does a very good job.

DTDGenerator FrontEnd Online interface; perl script written by Paul Tchistopolskii. Uses DTDGenerator, part of SAXON by Michael Kay. Also uses XP parser by James Clark. Browse to a local XML document and generate a DTD from your instance.
http://www.pault.com/Xmltube/dtdgen.html Requires local XML document (no URLs) as input.

Let's use DTDGenerator FrontEnd to generate our Collection DTD. Go to the above web site and press the Browse... button, and locate your local copy of the file collection1.xml which we used earlier. Press the Generate DTD! button. The generated DTD will appear in a new browser window. Use the browser's Edit|Select All choice and paste the DTD into a new text file. Alternatively, use the browser's Save As feature. The result should be identical (except for the first line or so) to the DTD collection1.dtd included in the earlier ZIP download.

So, why would anyone write a DTD by hand if this service exists? Well, first of all, a single XML instance does not necessarily represent the complete DTD any more than a single HTML file uses every possible element and attribute of HTML. For example, our collection1.xml example does not include Record, Poster, FlickerButton, or DrinkingCup elements that would be found in any true Beatles fan collection. They should be in the language even if they're not in my collection. Another reason (related to the first) is that there are many subtleties that might not be revealed by a single document instance, such as order of element nesting (content model), whether elements or attributes are optional, whether Book and CD elements need to appear in a certain order with respect to each other, etc.

Our example was purposely constructed to show that Rating and Note elements for Book elements were optional, that the country attribute of the Peak element is optional, and that there can be more than one Remastered element for a CD (since CDs are often remastered more than once so avid collectors will buy multiple copies). Look at the generated DTD (excerpted below) to verify these details were detected by DTDGenerator.

<!ELEMENT Book ( Title, Author, 
Type, Published, Rating?, Notes? ) >
<!ELEMENT CD ( Title, Artist, Chart, 
Type, Label+, AlbumReleased, Remastered+ ) >
<!ELEMENT Chart ( Peak+ ) >
<!ATTLIST Peak country NMTOKEN #IMPLIED >

The "?" after Rating and Notes confirms that these are optional elements; question mark means zero or one occurrence. The word "#IMPLIED" for the country attribute of the Peak element means that the attribute is optional. 3. The "+" after Remastered means one or more instances of this element are allowed (the same is true for Label and Peak).

This section is not meant to cover DTD syntax completely. See Selena's DTD tutorial or my Syntax Overview (which needs a little updating, but it is otherwise a good start).


3Actually, my intention was that if country is not specified, the default value should be "US". This is another example of something that would need to be added to the generated DTD.

Viewing It With IE5, Take 1
Doing It With XML, Part 1
Adding the DTD to Our ML


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




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, Reprints, & Permissions, Privacy Policy.

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