spacer

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

home / experts / xml / column66

dtddoc step 2: Internal data structures

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

After parsing XML DTDs with four different software packages in our last installment, we will look at the resulting data structures in Java, Perl, and PHP, respectively. This will be step two out of four in our creation of dtddoc:

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

Creating the internal data structure

We used the following parsers:

As demonstrated before, these parsers have a straightforward way of calling them on an input stream, creating an internal data structure in return. Let's examine those internal data structures in turn.

Bourret's DTD parser

Using DTDParser's parseXMLDocument() or parseExternalSubset() functions returns a DTD object for further inspection. The DTD object holds hashtables of entities and element types of the parsed DTD. An ElementType has various members that carry interesting information:

membervalue
attributesA Hashtable of attributes for the respective element type.
childrenA Hashtable of child ElementTypes.
contentA Group representing the content model of the element type.
contentTypeThe type of content, one of:
CONTENT_ANY: Any content type.
CONTENT_ELEMENT: Element content type.
CONTENT_EMPTY: Empty content type.
CONTENT_MIXED: "Mixed" content type.
CONTENT_PCDATA: PCDATA-only content type.
CONTENT_UNKNOWN: Unknown content type.
nameThe XMLName of the element type.
parentsA Hashtable of parent ElementTypes.

With this information, enumerating all element types and outputting the above information in HTML should be a snap. The content model's hierarchy can be easily navigated through the parents and children members of each element type.

on to inspecting the other tools' data structures...


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/column66/index.html
Created: Oct 14, 2002
Revised: Oct 14, 2002