Q: SW for parsing DTD's

Ron Bourret rbourret at dvs1.informatik.tu-darmstadt.de
Mon May 25 14:23:38 BST 1998


Stefan Mintert wrote:

> For the project I'm currently working on, I need to parse DTD's and query
> information like this:
> 
> - which elements are valid in a given context?
> - which elements can contain an element of a certain type?
> 
> 
> 
> Now I'm looking for software that does the parsing for me (Java classe are
> preferred) and provides a high-level interface.

MSXML returns DTD information in the form of a tree of XML-Data elements.  This 
will save you from parsing the DTD, but you will need to traverse this tree or 
build an additional tree structure on top of it to answer the questions you 
have.

There was a comment earlier on this list that MSXML cannot return information 
from external DTDs.  I haven't yet found where this is true, but I don't access 
schema information in all possible ways -- I just call tree.getDTD().getSchema() 
to return the root of the XML-Data tree.

XML-Data is probably richer than you need.  To explore the basic structure of a 
DTD, I use the following XML-Data elements and attributes (Simon -- here's a 
starting point):

Element Tag   Relevent part of the content model    Relevant attributes
-----------   ----------------------------------    --------------------
schema        elementType*                          id

elementType   ((element | group)* | empty | any |   id
               string | mixed)?, attribute*

element       essentially EMPTY                     type, occurs

group         (element | group)+                    occurs
                                                    groupOrder (SEQ and OR only)

empty         EMPTY                                 --

any           EMPTY                                 --

string        EMPTY                                 --

mixed         element+                              --

attribute     ???????                               --

-- Ron Bourret

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list