Parser for DTDs

Matt Mower (m.mower@unl.ac.uk)
Tue, 21 Apr 1998 14:06:43 +0000 (GMT)


Hi.

I am looking for a java parser that when fed a DTD returns a model
representing all the valid documents that can be expressed using that
DTD, i.e. for any given element type I need to be able to determine what
are valid sub-elements/attributes/content. One additional constraint is
that I need to parse the DTD outside of the context of an XML document.

I would ideally like to be able to write code something like :-

>DTDParser dp =3D new DTDParser( dtdInputStream );
>if( dp.isValid() =3D=3D true ) {
> Element[] childElems =3D dp.getRoot().getChildElements();
> Attribute[] attrs =3D childElems[0].getAttributes();
> =09
> if( childElems[0].isChildElement( "someelement" ) =3D=3D true ) {
> ...
> }
>}

I believe Larval may have this kind of capability (i'm not sure yet),
are there others?

Best regards.

Matt/

--=20
Matt Mower, Information Systems Team, University of North London
T: +44-(0)171-753-3288 F: +44-(0)171-753-5120 E: m.mower@unl.ac.uk