spacer

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

home / experts / xml / column65

dtddoc step 1: Parsing a DTD

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

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.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

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