murugu has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Is there any module avaialable for parsing a XML DTD and obtaining the tree structures of elements in the XML DTD.

Many Thanks in advance.

-Murugesan.

Replies are listed 'Best First'.
Re: XML DTD Tree Structure
by Roger (Parson) on Mar 02, 2004 at 13:51 UTC

      Thanks alot.

      Actually I want to view the DTD elements in Tree structure.

      does the module provided by you give the tree structure

      Many thanks in advance

      -Murugesan

Re: XML DTD Tree Structure
by mirod (Canon) on Mar 02, 2004 at 14:27 UTC

    Actually the elements in the DTD do not have a tree structure, as one element can be part of the model for several other elements.

    I haven't done this for XML DTDs, but for SGML ones I used dtdtree, from Earl Hood's old perlsgml tools. IIRC it processes the output of nsgmls, included in many Linux distributions, or found on James Clark website (you should go to that site anyway for instructions on how to get nsgmls to parse XML).

    perlsgml is pretty nice, and can completely document your DTD. You can see an example tree.

Re: XML DTD Tree Structure
by castaway (Parson) on Mar 02, 2004 at 14:45 UTC
    XML::LibXML does this best, I find.. (I cant remember why I didnt like the others, though) It's a little top heavy as it requires external libxml libraries etc, but it can do most everything XMLish you'll ever need (well, more or less, I worked on a 'validate/create skeleton XML from DTD' for a while, but it's now lying around mostly finished..

    C.