See Also: Home Links Personal Site Blogroll  FriendFeed CV

Tags:

Project Idea: XML Form Engine

I made the following notes back in July 2001 and have kept them for interests sake. These days of course XForms is the technology that has developed to meet this need

Aim:

To get around the messy problem of embedding HTML into CGI scripts (e.g. Perl) for FORM presentation and manipulation for the purposes of web based applications.

Kinda like the CGI perl module but use XML and try to fit into the semantic web idea describe interface layout (in XML) for both querying and rendering (using XSL) into HTML (or something else) for the purposes of an application (e.g. CGI app)

Might help seperate FORM and presenation from the program logic, in the same way HTML and CSS ought to be seperated

Performance is an issue. ie can we really afford to souce the XML, read the XSL, transform the XML source and present it to a client for every interface requirment for the application. Probably not with a perl module, but surely overhead would be minimal with an inbuilt XSLT engine (e.g. Xalan)

Could also pre-process the XML/XSL before use in the target application, and store the output for quick read acces in file system or database. Would take the run-time rendering load of the server but would still require insertion of application-state data values.

However, if a client is running a browser like IE5, Netscape-6, Opera-5 or Mozilla which have inbuilt XML/XSLT support, we could leave the rendering upto the client

A form should be able to contain any normal form elements..

  • input text
  • text area
  • radio button
  • select list
  • submit buttons

Dimensions and presentation assigned by device (e.g. Netscape 4.x needs narrower input fields) Accessed in OO way Add elements in a sequence based on XML description preload form items with data from description for default values set selected values (e.g. for Select lists)

To use:

  • parse form description definintion
  • create form object
  • add form elements
  • pre-load with data
  • tweak for device
  • return

XML Form Description:

XML description would be purely data oriented, ie data structure and not presentation. Could maybe use CSS or XSL for presentation after client-sniffing

Field values could be in any order, and manipulated for display later (as above)

An application will generally use multiple forms, so store them all in one XML file, and select them based on their id or name after parsing the file. After grabbing the XML, pass it through an XSL stylesheet which will handle presentation.

Don't need a value attrib as were gonna pass the values to the form renderer for display based on submitted CGI vals or other in programme generated ones.

<form name='test' id='123'>
<title>Here's the title of this form</title>
<description>And here might be a paragraph which describes in
detail what the user is to do when completing this form</description>
<body>
<input type='text' size='max' name='title' default='Some default text' />
<input type='radio' options='3' values='1,2,3' options='italy,france,belgium' />
</body>
</form> 

HTML rendering:

<form name='test'>
<input type='text' name='title' value='' defaultVal=''>
<input type='radio' name='radiotest' value='option1' SELECTED>
<input type='radio' name='radiotest' value='option2'>
<input type='hidden' name='secret' value=''>
<input type='submit' value='Save This Record'>
</form>

Web References:

The Semantic Web http://www.w3.org/2001/sw/

RDF (resource description framework) http://www.w3.org/RDF/

Perl and XML http://www.xml.com/pub/a/98/09/xml-perl.html

Using XML and Relational Databases with Perl http://www.xml.com/pub/a/2000/12/13/perlxmldb.html

XML-XSLT http://xmlxslt.sourceforge.net/ http://search.cpan.org/search?dist=XML-XSLT

Xalan - XSLT processor http://xml.apache.org/xalan-c/index.html

XSLT Processors Index http://www.xmlsoftware.com/xslt/

CGI-FormMagick http://search.cpan.org/search?dist=CGI-FormMagick

HTML Form Validator http://search.cpan.org/doc/FRAJULAC/Apache-iNcom-0.09/lib/HTML/FormValidator.pm

CGI-Formalware http://search.cpan.org/search?dist=CGI-Formalware


See Also: Project Ideas | XMLTechnologies | Web Development | Notes Index