With the current DOMParser you can: DocumentTypeImpl dtd = ((DocumentImpl)doc).getDoctype(); NamedNodeMap map = dtd.getElements();
Chris Gokey wrote: > Hi everyone, > > I'm hoping that someone could point me in the right direction regarding > what > classes I need in order to access element definitions in a DTD. > > Consider the following DTD: > > <!ELEMENT Personnel (Role+, First_Name?, Middle_Name?, Last_Name?, > Email*, Phone*, FAX*, Address?)> > > <!ELEMENT Role (#PCDATA)> > <!ELEMENT First_Name (#PCDATA)> > <!ELEMENT Middle_Name (#PCDATA)> > <!ELEMENT Last_Name (#PCDATA)> > <!ELEMENT Email (#PCDATA)> > <!ELEMENT Phone (#PCDATA)> > <!ELEMENT FAX (#PCDATA)> > <!ELEMENT Address (#PCDATA)> > > I'd like an API something like this: > > // some class that would parse a DTD and create an intermediate > representation > for > // accessing its elements (like a DOM). > DTDParser parser = new DTDParser(); > parser.parse("dif.dtd"); > > ElementList list = parser.getElements(); > int len = list.getLength(); > for (int i=0; i<len; i++) { > String elementName = list.item(i).getElementName(); > String definition = list.item(i).getDefintion(); > System.out.println("elementName="+elementName); > System.out.println("definition="+defintion); > System.out.println("\n"); > } > > In which the code above might produce the following output: > > elementName = Personnel > definition = (Role+, First_Name?, Middle_Name?, Last_Name?, > Email*, Phone*, FAX*, Address?) > > elementName = Role > definition = (#PCDATA) > > elementName = FirstName > defintion = (#PCDATA) > > . > . > . > > I would imagaine the Xerces library must have something to help me achieve > this functionality? > > Thanks in advanced... > > Chris > > -- > Christopher D. Gokey, Raytheon ITSS, NASA/GCMD > 18 Martin Road, Shelburne Falls, MA 01370 > Phone: Voice (413) 625-8129 / FAX 208-248-9055 > [EMAIL PROTECTED] / http://gcmd.nasa.gov -- <person name="Ralf I. Pfeiffer" loc="IBM JTC, Cupertino, CA" email1="[EMAIL PROTECTED]" email2="[EMAIL PROTECTED]" />