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

Hi Monkers,

Does anyone know of a PERL Package or some code that will generate an HTML form using a DTD.

The idea is that:

  1. the code will read the DOCTYPE from an XML document instance submitted in the web browser,
  2. the code then GETs that DTD using the DOCTYPE URI,
  3. the code then creates an HTML form according to that DTD's structure,
  4. the content of each HTML form element is filled by the content of the relevant element in the XML document instance,
  5. the user can then edit the content in the HTML form,
  6. submit it and the result is an XML document instance that is valid against the DTD.

I know how to do all this except step 3.

I don't think that I can use XSL because the DTD changes according to that defined in the previous HTML form submission and thus there would have to be an XSL for every possible DTD.

Can anyone please help me?

Thanks.

Replies are listed 'Best First'.
Re: Generating HTML forms from a DTD
by CountZero (Bishop) on Jul 03, 2003 at 06:46 UTC

    I don't think that you can derive an HTML-form from a DTD as each DTD defines an arbitrarily large number of documents. I mean, once you have an HTML (or XML) document, you can check if they are valid according to a particular DTD, but from the DTD in general you cannot generate one single document. (Well perhaps you can but only in the most simple of cases where you have a DTD that has no room for alternatives or so.)

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Generating HTML forms from a DTD
by bobn (Chaplain) on Jul 03, 2003 at 03:16 UTC

    What do you mean by "the code then creates an HTML form according to that DTD's structure"?

    I know a little about XML, and about HTML forms and I haven't a clue as to what you mean.

    also, you state that the final output is an XML document, but that the DTD changes as a result of the submission, which leads me to believe that one of us (probably you) is confused, since DTD is not XML.

    Could you provide a small example of the input and output you intend?



    --Bob Niederman, http://bob-n.com