Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Tree [r15] /

File Date Author Commit
img 2008-11-30 numberone [r1] initial release
README 2008-12-11 numberone [r13] style, minor bugs
SForm.pm 2008-12-11 numberone [r13] style, minor bugs
example.xml 2008-12-02 numberone [r11] documentation
example.xsd 2008-12-11 numberone [r13] style, minor bugs
generate.cgi 2008-12-02 numberone [r11] documentation
index.html 2008-12-02 numberone [r11] documentation
save.cgi 2008-12-02 numberone [r11] documentation
sform.js 2008-12-11 numberone [r13] style, minor bugs
style.css 2008-12-11 numberone [r13] style, minor bugs

Read Me


1. there must be at least two global simpleType and complexType 
   to work correctly


SchemaForms -- Web-based forms based on XML-Schema 

SchemaForms is a toolkit for generating HTML forms from XML-Schema
description, optionaly preloading them from supplied XML file, with
ability to save submitted form data again to XML file.

Only a subset of XML-Schema is recognized during displaying the form
(see specification below) and an additional attributes in XML-Schema are 
required to behave SchemaForms correctly. These are used to determine
appropriate layout and style of form and form fields.

Package description

SchemaForms toolkit consists of:

   -- server-side perl library containing XML-Schema and XML 
      manipulation code, used by generate.cgi and save.cgi.

	-- server-side wrapper used to generate HTML form (both 
       structure and content) from XML-Schema and XML file, 
       to the format readable by JavaScipt.

	-- server-side wrapper used to save submitted form data into 
       XML file (optionally by validating against XML-Schema).

	-- example of integration of SchemaForms into a web page. 
       Generates form based on example.xsd XML-Schema, saving 
       data to example.xml XML file. JavaScript representing
       form and data definition is dynamically loaded using 
       generate.cgi script.

	-- static JavaScript code used to build and manage HTML form. 

Integration of SchemaForms with YOUR application

Modify your web page according to index.html, including img/ files,
style.css file, sform.js and generate.cgi?... JavaScripts. Use onload
event to initialize SchemaForms.

You will need to add code for retrieving your XML file name to the
generate.cgi script (see $xsd_filename, $element_name and $xml_filename 
variables on the top of generate.cgi), based on your application logic.

The same apply for save.cgi. To save submitted data to the XML file, you 
should send an object identifier from (hidden) field in form to your version
of save.cgi script and compute correct path name to XML file.

Feel free to change generate.cgi and save.cgi as you need. If you have
perl-based application, you can even use SForm library directly.

If you need to add your own type of form field ('widget'), look at
Line* or Type* classes in sform.js and include another JS file with 
your widget implementation.

Defining form fields layout and style

TODO: In this chapter following _should_ be described:

	- form: options
	- Type* classes
	- Line* classes

Supported subset of XML-Schema

Not all XML-Schema features are supported by SchemaForm. 
Only following XML-Schema elements are supported:

	simpleType* $name sTdef
	complexType* $name cTdef
	attribute* $default? $name [ $type | simpleType ]
	element+ $default? $name [ $type | simpleType | complexType ]

element $default? $min/maxOccurs?
		[ $ref | $name [ $type | simpleType | complexType ] ]

attribute $default? $use=("Optional"|"required")="1/1"? 
			[ $ref | $name [ $type | simpleType ] ]

simpleType sTdef

	restriction [ $base | simpleType ]
		enumeration* $value - form:render="TypeEnum"
		pattern* $value - kontrola JavaScriptem?
		# min*, max*, length*??

complexType [mixed!="true"] cTdef

		extension $base
		extension $base

In short we DO NOT support following XML-Schema features:

	* xs:union
	* xs:choice
	* xs:all 
	* xs:any
	* xs:complexContent
	* xs:complexType mixed=true