ImagoX Forms Extension
The ImagoX Forms Extension is an implementation of a forms
processor. ImagoX Forms was designed with these goals:
The elements and attributes listed here use the name spaces defined in the imagoX_form.xml and imagoX_extension.xsl files. While the xform name space is not required, a name space must be used. The name space of the root element in the XML document will be used to detect all element and attributes of the form and, except where noted, as the name space on all output elements and attributes. ![]() The root element of the form. Only one root element may exist in a single name space. The actual name of the element does not need to be root, this is the element that will trigger the org.xenei.imagoX.ImagoForm.root() extension element as defined in the XSLT file. During validation the root node is replaced with a copy. See copy section below for details. Attributes:
![]() The hidden node and all its child nodes are removed during the GET operation. During the POST operation all children are made siblings of this node and this node is removed. Compare with xform:remove. ![]() The remove node and all its child nodes are removed during the POST operation. During the GET operation all children are made siblings of this node and this node is removed. Compare with xform:hidden. ![]() The input node defines an input field. The input note may have the following attributes: Attributes:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
All field validators listed here are in the org.xenei.imagoX.forms
package. FieldValidator
ChoiceValidator
DateValidator
EmailValidator
ImageValidator
NumberValidator
SelectValidator
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
Many of the input types, the root node and any node in the
xform name space not listed above is copied from the input document to the output
document after validation according to the following process. If the element has an xform:remove attribute the element and all enclosed children are removed. Nothing is added to the result and the copy is complete. Otherwise if the xform:name attribute is specified the new element name will be set to that value. This may be a fully qualified name or a simple name. If a simple name is specified the element will not have a name space defined. If not specified and the element is in the xform namespace the result element will be called xform:unknown; otherwise the element will be cloned. Next any attributes that are not in the xform name space are copied to the result and the result returned. If the prefix (xform in our examples) of the new element is not known in the current transform its URI may be specified with the xform:NS attribute. If the name space is known this attribute is ignored. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
ImagoX Forms is a good candidate for the Launcher mechanism,
otherwise it must create a new instance of the field validators on each request.
The configurations passed to the ImagoForm class must list the input types and classes
that will validate those types. The types listed in the configuration file become
valid xform:type attribute values for the xform:input elements. ImagoX extension configuration information is available here. The following configuration lines go into the imago.properties file. The method of configuring Forms depends upon the choice of configuration style. The two styles are shown below. Launcher-style configuration init.Launcher.class.Forms=org.xenei.imagoX.forms.ImagoForm imago.properties-style configuration org.xenei.imagoX.forms.ImagoForm.number=org.xenei.imagoX.forms.NumberValidator |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Sample Form XML
Below is a simple XML example of an ImagoX Form.
<?xml version="1.0"?><!DOCTYPE document SYSTEM "imago.dtd"> <document xmlns:xform="http://xenei.org/imago/XForm/2003"> <meta> <title>ImagoX Form Example</title> <author> <name>webmaster</name> <email>webmaster@xenei.org</email> </author> </meta> <content> <xform:root name="formRoot"><xform:form> <test name="Name"><xform:input xform:name="name" xform:type="text"/></test> <test name="Password"><xform:input xform:name="pw" xform:type="password"/></test> <test name="Number"><xform:input xform:name="number" xform:type="number"/></test> <test name="Email"><xform:input xform:name="email" xform:type="email"/></test> <test name="Date"><xform:input xform:name="date" xform:type="date"/></test> </xform:form></xform:root> </content> </document> Once the above XML has been validated the result would be the
following document:
<!DOCTYPE document SYSTEM "imago.dtd"> <document xmlns:xform="http://xenei.org/imago/XForm/2003"> <meta> <title>ImagoX Form Example</title> <author> <name>webmaster</name> <email>webmaster@xenei.org</email> </author> </meta> <content> <formRoot> <test name="Name"><name>My Name</name></test> <test name="Password"><pw>MyPassword</pw></test> <test name="Number"><number>123</number></test> <test name="Email"><email>someone@xenei.org</email></test> <test name="Date"><date xform:monthNum="6" xform:day="10" xform:year="1959" xform:calendar="java.util.GregorianCalendar" xform:month="May" xform:value="11292897198"/></test> </formRoot> </content> </document> |