Generating a form from an XML schema

A returning question on the cocoon user list is "Can I generate a Cocoon Form from an XML schema?". At Hippo (http://www.hippo.nl), we have built several websites that make use of this concept. I have put together a small example that demonstrates transforming an XML schema into a Cocoon Forms definition, template and binding using three similar XSLs.

The XSLs in this example were actually one of my firsts attempts at XSL/Schema/Cocoon, so they are not examples of very good programming. In addition, they can only transform schemas of a certain, very simple and restricted structure. These XSLs should be considered as a proof of concept, rather than an example of how it should be done.

The difficulty with schemas is that they can contain an implicit structure by means of references to elements. The example XSLs can transform schemas with the following structure: a root element containing references to a number other elements, each having a number of child elements. See the included schema for an example. Try to edit the schema and see the form adapt to it. Making forms has never been easier ;)

Installation notes

  1. Install Cocoon 2.1.9
  2. Create a folder schema2form under your cocoon/webapp folder.

  3. Download schema2form_cocoon_2_1_9.zip and unzip it inside schema2form.

  4. Start Cocoon
  5. Point your browser to http://localhost:8888/schema2form/form-example

The ZIP file contains 8 files:

Remarks

Feedback wanted

If you have difficulties on getting the example up and running, or if you have any comments, please send me an email and I will try to help. Also feel free to add useful info to this Wiki page.

NielsVanKampenhout

Schema2CocoonForms (last edited 2009-09-20 23:42:11 by localhost)