Actually XML::Parser reads the DTD, and in 2.28 and later
gives you quite a bit of information about it, so you
could use it to generate a tree, that you could then walk
(choosing at random when faced with an alternative, or just
generate _all_ alternatives and choose the shortest or
some other more sophisticated heuristic) to generate a
valid instance.
An alternative to generating atree would be to generate a
Parse::RecDescent grammar and then I think you can use a
feature of Parse::RecDescent that let's you generate a
valid instance conformant to the grammar.
I did that a long time ago, in C, to generate test documents
for an SGML project I was working on and it worked fine,
except that it was not based directly on the DTD. You
usually need more information than a DTD will give you
(what kind of text is expected, what kind of ID/REFID
links do you want to generate etc...)
|