http://qs321.pair.com?node_id=416443

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

Dear Enlightened,

Are there any Perl resources for generating XML fragments from a DTD? I would like to use a DTD to create XML templates, which I can then modify.

Thanks for your help,

loris

  • Comment on Perl resources for generating XML fragments from a DTD?

Replies are listed 'Best First'.
Re: Perl resources for generating XML fragments from a DTD?
by Aristotle (Chancellor) on Dec 21, 2004 at 13:02 UTC

    It shouldn't be hard to do that using XML::ParseDTD — that is, in those cases where it's feasible. After all, if element A may contain element B, and element B may contain element A, there's no way for the generator to know when to stop nesting. I suppose you could just create minimal templates with only the minimum required tags the DTD demands — for the cases I can think of right now, that is always a finite set if not one with only a single member.

    Makeshifts last the longest.

Re: Perl resources for generating XML fragments from a DTD?
by gmpassos (Priest) on Dec 22, 2004 at 02:07 UTC
    You can take a look at XML::Smart::DTD take comes with XML::Smart. It has a set of methods to get informations from the DTD parsed by it.

    You also can take a look in the methods apply_dtd() of XML::Smart, since it will automatically create XML files with the default values and format of the DTD.

    Graciliano M. P.
    "Creativity is the expression of liberty".