spacer

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

home / experts / xml / column65

dtddoc step 1: Parsing a DTD

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Now that we have looked at the -- to my knowledge -- only tool for documenting DTDs, let's get started with our own development effort. This can be broken down into the following steps:

  1. Parsing a DTD
  2. Creating the internal data structure
  3. Adding element and attribute descriptions
  4. Generating HTML

We will look at the first step today and leave the others to later installments of this column.

Parsing a DTD

A DTD parser has the job of reading a textual representation of a DTD and transforming it into an in-memory representation suitable for further manipulation in the respective programming language. Instead of writing a DTD parser ourselves, we find these software packages on the Web:

All of these parsers have a straightforward way of calling them on an input stream and creating an internal data structure in return.

Bourret's DTD parser

With Bourret's parser you simply create a DTDParser and call either parseXMLDocument() or parseExternalSubset(), depending on whether the DTD is embedded in the XML document or external to it:

import org.sax.InputSource;
import org.xmlmiddleware.schemas.dtds.DTDParser;
import org.xmlmiddleware.schemas.dtds.DTD;

DTDParser parser = new DTDParser();
InputSource is = new InputSource("html4.dtd");
DTD dtd = parser.parseExternalSubset(is, null);

Parsing DTDs with the other tools...


Produced by Michael Claßen

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
DiVitas's Mobile UC Now Available on the Latest Devices · Review: FON Fonera 2.0n · Chip Market Recovering From '08 Collapse

URL: http://www.webreference.com/xml/column65/index.html
Created: Sep 30, 2002
Revised: Sep 30, 2002