Here, I describe my experience with XFORMS:(W3C) XForms is an XML application that represents the next generation of forms for the Web. By splitting traditional XHTML forms into three parts—XForms model, instance data, and user interface, it separates presentation from content, allows reuse, gives strong typing—reducing the number of round-trips to the server, as well as offering device independence and a reduced need for scripting.
XForms currently requires the XForms-plugin for Firefox. This plugin is available https://addons.mozilla.org/en-US/firefox/addon/824. The current post was written using Mozilla XForms 0.8.6ff3.
In this post I show how to send a RDF+XML document describing a SNP to a web server using XForms. The form contains a field for the name of the SNP. It also contains a table with two columns (chromosome and position) for mapping the SNP. As this SNP could be mapped more than once on the genome (don't use this for genotyping !), the user will be able to append a row at the end of the table for each position.
Note: The file must be an Xhtml file and the form must send its data to the same domain.
The <HEAD> contains the <xforms:model> This element represents a form definition and is used as
a container for elements that define the XForms Model.
<xforms:model> contains the <xforms:instancel>. An instance defines a template for the data to be collected. Here the template is a RDF file describing a SNP. This SNP is mapped twice.
We then bind the node of this instance to an unique descriptor using an xpath expression. Note that the attribute
@typecan be used to add a restriction to this form (for example the position must be a non-negative integer), if the form is not validated, the data won't be send to the server. A finer validation could also be performed if an XSD schema was attached to the model. Note also that the @rdf:about (a link to the ncbi for the SNP) attribute will be calculated from the name of the SNP.
We then describe how the data should be submited. Here are two <xforms:submission>: one send the data as XML just like a regular html form, the other send a mail (this second form didn't worked).
Then, the input fields are written in the body of the XHTML document. Each field contains a
xforms:labelas well as a
xforms:alertdisplayed if the field is not valid.
For each position of this SNP, the fields are inserted in a table using <xforms:repeat>
A button is used to append a new row in this table:
And at the end, here are the two 'submit' buttons:
... and in the header, a little piece of CSS for styling:
And here is the XML sent to the server
All in one...