A XSLT transformation will be applied to the XML specification in order to create a XHTML form which will be inserted in the page.

That form can be filled and will generate XML respecting the structure of the starting specification.

More technical information can be found in the explanation text.

Form generation

Here are the steps to follow :

  1. Choose a RelaxNG or a XSD schema from the list.
  2. Before generating the form, you may change the default value (9) of the maximum numbers of ref/define followed in the schema. Some schemas are huge, that may be important for you to read it more deeply.
  3. Click on "generate form" to get the XHTML form generated from that specification.
  4. (optional) Choose an example file and click on "initialize form".
  5. (optional) Reset form by clicking on "reset form".
  6. Enter values in the form. Add or remove an element with the "+" and "-" buttons.
  7. Click on "Generate XML" in order to dump values in XML.

In a second time, the values entered in the form generate the XML respecting that specification.

Benefits

When facing XML specification the first problem I encountered is trying to reuse an existing standard. Reading (and understanding) a XML specification is very painfull, especially if it is written using XSD. RelaxNG does not solve that problem, but at least reduces the complexity of the schemas, and it also reduces a bit their verbosity.

So one first thing I wanted to do was to see a schema in the form of a form :-). That way I see the values which will be entered in that XML as input fields, with the markups around it. In a second time, I will also be able to generate an example of a XML which respects that specification.

Explanation

If the input XML specification is a XSD schema, it will be converted into RelaxNG with a XSLT tranformation better described in XSD to RelaxNG section of that web site. Then the RelaxNG schema will be transformed into a XHTML form by another XSLT named RNGtoHTMLform.xsl. You will also find the correspondance table between the RelaxNG markups and what it creates in the form.

One important thing to understand about that form generation is that each input field of that form is marked with an attribute "name" which contains the XPath expression which points on that value in the XML.

When submitting that form, the javascript will read the values and generates the corresponding XML. The algorithm which does that is described there. It supports namespaces.

The generated XML can be validated with a call to the server which will use a classic XML API.

Participation

All those developments are released under Cecill licence.

The project Forms Generator is available on a svn, contact me for more information. In the future, a project might be created on sourceforge.

Projects svg 3d, XSD to RelaxNG converter, javascript SAX parser, javascript RelaxNG validator, javascript datatype library are published on Google code. Project javascript SAX parser is also published on Github.

Requirements

In order to have javascript working as expected, please use last version of firefox.

For the applets, you will need to have java installed on your computer.