Table of Contents
This chapter provides the manual documentation of XformEditor tool. It is also available as online documentation with the tool.
Table of Contents
Simple files located on a server directory are used to store XForm and language documents. Each project has its own folder, and each activity has a folder inside its project's folder. The repository.xml file specifies the XForm files associated with projects and activities. In the example, an activity (approval1) has an associated XForm file, named xform.xhtml; however, its project does not have an XForm file.
<repository> <project> <projectname>XformEditorDemo</projectname> <projectversion>1.0</projectversion> <activities> <activity> <activityname>approval1</activityname> <activityxformfile>xform.xhtml</activityxformfile> </activity> </activities> <projectxformfile>xform.xhtml</projectxformfile> </project> </repository>
When any project or activity is started in JiapAdmin, the repository file makes it possible to know if any XForm documents exist. If there are no XForm documents for a project, formgenerator application builds a new XForm. If an XForm file is found, then formgenerator will apply the data to the existing XForm file, choosing the corresponding language file. Using static XForms it is possible to:
Move form elements, customize properties order.
Change an input element to a textarea element, and vice versa.
Set form labels in different languages.
Specify a property's data type.
Set XForm element attributes: readonly, required, and relevant.
Table of Contents
The purpose of this tutorial is to provide the user with basic information about XForm Editor and XForms.
"Forms are an important part of the Web, and they continue to be the primary means for enabling interactive Web applications. Web applications and electronic commerce solutions have sparked the demand for better Web forms with richer interactions. XForms 1.0 is the response to this demand, and provides a new platform-independent markup language for online interaction between a person (through an XForms Processor) and another, usually remote, agent. XForms are the successor to HTML forms, and benefit from the lessons learned from HTML forms."
The following are the primary benefits:
XForms improves the user's experience.
XForms has been designed to allow many things to be checked by the browser, such as types of fields being filled in, if a particular field is required, or if one date is more current than another. This reduces the need for round trips to the server or for extensive script-based solutions. It also improves the user's experience by providing immediate feedback to what is being filled in.
It is XML, and it can submit XML.
XForms is properly integrated into XML: it is in XML, the data it collects in the form is XML, it can load external XML documents as initial data and can submit the results as XML. By including the user in the XML pipeline, end-to-end XML right up to the user's desktop is available.
It combines existing XML technologies.
Rather than reinventing the wheel, XForms uses a number of existing XML technologies, such as XPath for addressing and calculating values, and XML Schema for defining data types. This has a dual benefit: ease of learning for people who already know these technologies, and the ability for implementors to use off-the-shelf components to build their systems.
It is device independent.
The same form can be delivered without change to a traditional browser, a PDA, a mobile phone, a voice browser, and even some more exotic emerging clients, such as an Instant Messenger. This greatly eases the task of providing forms to a wide audience, since forms only need to be authored once.
It is easier to author complicated forms.
Because XForms uses declarative markup to declare properties of values and to build relationships between values, it is much easier for the author to create complicated, adaptable, forms, without having to resort to scripting.
It is internationalized.
Because the data submitted is XML, it is properly internationalized.
It is accessible.
XForms has been designed so that it will work equally well with accessible technologies (for instance, magnified browsers for visually-impaired users) as with traditional visual browsers.
Check data values while they are being typed in by the user.
Indicate that certain fields are required, and that the form cannot be submitted without these fields.
Submit forms data as XML.
Integrate with Web services, for example by using SOAP and XML RPC.
Submit the same form to different servers (for example, a search string to different search engines).
Save and restore values to and from a file.
Use the result of a submit as input to a further form.
Get the initial data for a form from an external document.
Calculate submitted values from other values.
Constrain values in certain ways, such as requiring them to be in a certain range.
Build 'shopping basket' and 'wizard' style forms without having to resort to scripting.
XForm Editor allows an existing XForm document to be edited or a new XForm document to be built from an xml data flux. Moreover, XForm Editor provides the capability of internationalizing XForms by choosing desired languages. To build new XForms, XForm Editor analizes data obtained from a generic xml flux and creates corresponding XForm elements, joining to each one a bind element containing its properties. Inside each element's label is a reference to the corresponding label id, which allows the corresponding label name to be found in the language files.
<process> <name>XformEditorDemo</name> <Version>1.0</Version> <properties> <property id="Id"> <value/> <type>input</type> </property> <property id="ProductName"> <value/> <type>input</type> </property> <property id="Description"> <value/> <type>input</type> </property> <property id="Type"> <value>solid</value> <type>select</type> <possible-values> <possible>solid</possible> <possible>liquid</possible> <possible>gaz</possible> </possible-values> </property> <property id="Custumer"> <value>Carrefour</value> <type>selectd</type> <possible-values> <possible>Carrefour</possible> <possible>Casino</possible> </possible-values> </property> <property id="stock"> <value/> <type>input</type> </property> </properties> </process>
<html xmlns="http://www.w3.org/2002/06/xhtml2" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <head> <title>XForm</title> <xf:model id="model"> <xf:instance id="instance" src="contextobject:$instance"/> <xf:instance id="lang" src="contextobject:$lang"/> <xf:submission action="" id="bValider" method="post" replace="all"/> <xf:bind constraint="" id="b Id" nodeset="properties/property[@id='Id']/value" readonly="false()" relevant="true()" required="true()" type="integer"/> <xf:bind constraint="" id="b ProductName" nodeset="properties/property[@id='ProductName']/value" readonly="false()" relevant="true()" required="(//properties/property[@id='Type']/value != 'solid')" type="string"/> <xf:bind constraint="" id="b Description" nodeset="properties/property[@id='Description']/value" readonly="false()" relevant="true()" required="false()" type="string"/> <xf:bind constraint="" id="b Type" nodeset="properties/property[@id='Type']/value" readonly="false()" relevant="true()" required="true()" type="string"/> <xf:bind constraint="" id="b Custumer" nodeset="properties/property[@id='Custumer']/value" readonly="false()" relevant="true()" required="true()" type="string"/> <xf:bind constraint="" id="b stock" nodeset="properties/property[@id='stock']/value" readonly="false()" relevant="true()" required="false()" type="integer"/> </xf:model> </head> <body> <xf:group appearance="full"> <xf:label id="projectname" ref="instance('lang')/string[@id='XformEditorDemo']"/> <xf:input bind="b Id" content="no" extattr="project" id="Id"> <xf:label ref="instance('lang')/string[@id='Id']"/> <xf:alert ref="instance('lang')/string[@id='alert']"/> </xf:input> <xf:input bind="b ProductName" content="no" extattr="project" id="ProductName"> <xf:label ref="instance('lang')/string[@id='ProductName']"/> <xf:alert ref="instance('lang')/string[@id='alert']"/> </xf:input> <xf:textarea bind="b Description" content="no" extattr="project" id="Description"> <xf:label ref="instance('lang')/string[@id='Description']"/> <xf:alert ref="instance('lang')/string[@id='alert']"/> </xf:textarea> <xf:select1 appearance="full" bind="b Type" content="no" extattr="project" id="Type"> <xf:label ref="instance('lang')/string[@id='Type']"/> <xf:alert ref="instance('lang')/string[@id='alert']"/> <xf:itemset nodeset="instance('lang')/possible-values[@id='Type']/possible"> <xf:label ref="."/> <xf:value ref="@id"/> </xf:itemset> </xf:select1> <xf:select appearance="minimal" bind="b Custumer" content="no" extattr="project" id="Custumer"> <xf:label ref="instance('lang')/string[@id='Custumer']"/> <xf:alert ref="instance('lang')/string[@id='alert']"/> <xf:itemset nodeset="../possible-values/possible"> <xf:label ref="."/> <xf:value ref="."/> </xf:itemset> </xf:select> <xf:submit submission="bValider"> <xf:label ref="instance('lang')/string[@id='submit']"/> </xf:submit> <xf:input bind="b stock" content="no" extattr="project" id="stock"> <xf:label ref="instance('lang')/string[@id='stock']"/> <xf:alert ref="instance('lang')/string[@id='alert']"/> </xf:input> </xf:group> </body> </html>
<strings> <string id="XformEditorDemo">XformEditor Demonstration </string> <string id="alert">Error : fill in this field</string> <string id="Id">Identifier of the product</string> <string id="ProductName">ProductName</string> <string id="Description">Description of the product</string> <possible-values id="Type"> <possible id="solid">solid_toto</possible> <possible id="liquid">liquid</possible> <possible id="gaz">gaz</possible> </possible-values> <string id="Type">Type</string> <string id="Custumer">External Custumers </string> <string id="stock">Number of products in the stock</string> <string id="submit">Submit</string> </strings>