This Version: V 0.1 (27 September 2004)
Latest Version: http://brainattic.info/examploforms/
Previous Version: none
Examploforms 0.x is an extension of Examplotron designed to facilitate form modeling and authoring, in particular for XForms. It also includes XML Schema datatype libraries useful for forms.
Possibly setting some kind of record, the name Examploforms derives from Examplotron, which in turn derives from the name Schematron, which derives from earlier sources.
Editor:
The purpose of examploforms is to make it easier to model and write complex, real-world forms. Authoring such forms is a multi-step process, including at least the following major steps:
date_married is relevant only when
../has_spouse is 'true'.Often these steps are taken out of order, or in parallel by separate teams, possibly with graphical WYSIWYG tools. Examploforms merges the steps of specifying the XML and mapping the relationships, which makes it best suited for forms being designed from scratch, including a large number of forms currently managed via conventional paper processes.
One goal of Examploforms is that a valid XForms data instance can be obtained by stripping of the Examplotron and Examploforms markup from a valid Examploforms document. It should also be easily possible from XSLT to convert Examploforms into a full-fleged XForms document suitable for rendering in Chiba, formsPlayer, or any other XForms engine.
Like Examplotron, this document maintains a strong emphasis in meeting the iconic 80% of functionality that's most useful while remaining comprehensible.
This release is an initial version. I welcome community feedback and suggestions.
While namespace prefixes may be arbitrarily assigned, this document consistently uses them as follows:
In this release, Examploforms pays little attention to the needs of mapping attributes to form values, as the annotations themselves are declared in attributes. Future editions may address this.
This initial release focuses on ideas and technology, not optimization, form appearance, or marketing concerns.
Before getting into Examploforms itself, a few useful tools need to be explained. These datatype libraries serve as naming conventions for commonly derived classes of XML Schema datatypes.
A common requirement of forms of all types is that certain existing datatypes have an additional limitation as to the length of allowed
values. For example, the name field in a database might be limited to 45 characters, and thus the form that eventually produces
that string should enforce the same limitation. In some cases, a minimum length limit is also desirable.
This datatype library consists of the set of all datatypes that can be derived from existing XML Schema datatypes defined in either XML
Schema part 2 or XForms, restricted by either 1) the maxLength facet alone, or 2) the maxLength and
minLength facets. Like all such datatype libraries, it is defined in a namespace. The offical namespace name, however, has not
yet been defined. In this document, the prefix dt: represents this library.
The name of a datatype that defines only a maxLength facet is as follows:
dt: is the prefix assigned to the datatype library's namespace name, dtname is the name of a datatype
defined in either XML Schema part 2 or XForms, - is a literal dash character, and 99 represents any positive
integer and is the value assigned to the maxLength facet.The name of a datatype that defines both maxLength and minLength facets is as follows:
dt: is the prefix assigned to the datatype library's namespace name, dtname is the name of a datatype
defined in either XML Schema part 2 or XForms, - (both occurrences) is a literal dash character, 88 represents a
positive integer and is the value assigned to the minLength facet, and 99 represents any positive integer and is
the value assigned to the maxLength facet. The maxLength value must be greater than or equal to the
minLength value.Thus, the name of a datatype in this library contains sufficient information to construct a full XML Schema part 2 derived datatype. For
example, a name restricted to 45 characters would be dt:string-45, shorthand for this:
<xs:simpleType name="string-45">
<xs:restriction base="xs:string">
<xs:maxLength value="45"/>
</xs:restriction>
</xs:simpleType>
A common requirement of forms is that certain allowed values are restricted to a finite enumeration, often presented in a list format. For
example, the officer field in a data collection system might be required to have one of the values president,
vice_president, or treasurer.
This datatype library consists of the set of all datatypes that can be derived from the XML Schema string datatype, restricted
by the enumeration facet with specified values. Like all such datatype libraries, it is defined in a namespace. The official namespace name,
howerver, has not yet been defined. In this document, the prefix dt: represents this library.
The name of a datatype that defines an enumerated type is as follows:
dt: is the prefix assigned to the datatype library's namespace name, enum and all occurrences of
- are literal strings, and val1, val2, val3, and any subsequent hypen-delimited
strings, are possible values of the enumeration. Enumeration values cannot contain hyphens or any character not allowed in a datatype name.Thus, the name of a datatype in this library contains sufficient information to construct a full XML Schema part 2 derived datatype. For
example, and enumeration of president, vice_president, or treasurer would be
dt:enum-president-vice_president-treasurer, shorthand for this:
<xs:simpleType name="enum-president-vice_president-treasurer">
<xs:restriction base="xs:string">
<xs:enumeration value="president"/>
<xs:enumeration value="vice_president"/>
<xs:enumeration value="treasurer"/>
</xs:restriction>
</xs:simpleType>
This first example document can be used to create a simple form:
<?xml version="1.0" encoding="UTF-8"?> <foo xmlns:eg="http://examplotron.org/0/"> <bar eg:content="dt:string-20">My first Examploform.</bar> <baz>Hello World!</baz> </foo>
This document represents a form with a single input control, with an initial value of "My first Examploform", which as it
happens, is longer than the maximum-allowed 20 characters. After that problem is corrected by the user, the form can be submitted as XML,
using the data structure shown. The actual data entered by the user would replace any initial values given.
Note: This is not to say that POSTing an XML instance is automatically the best thing a form can do during submission.
In many cases, a RESTful GET is the appropriate solution, and one that XForms handles smoothly. Even with GET,
though, the form data still needs to be initially modeled as XML.
XML documents can have many nodes, not all of which are intended to be mapped to fillable form controls. In the example above,
bar is mapped to a form control, while baz remains avaialable as data, but not mapped to a form control. In classic
HTML forms, this would be called a "hidden field". A later section describes the rules for determining how form controls map to the instance
data.
Much of the power of XForms comes from the ability to define XPath-based relationships between various nodes of the instance data, including dynamic control over calculations, validations, and whether a node is required, read-only, or relevant. The combination of an XPath node with these properties is called a Model Item Property, and Examploforms makes these easeier to write and visually inspect, since they appear 'inline', at the point where they take effect.
The following Model Item Properties can be controlled through Examploforms:
true for this element node to be considered valid.true, indicates the element node is
required.true, indicates the element node is
read-only.true, indicates the element node is relevant,
and will thus be included in data submission.The following example illustrates.
<taxpayer xmlns:eg="http://examplotron.org/0/" xmlns:ex="http://examploforms.org/0/"> <name eg:content="dt:string-45">Full name here</name> <married eg:content="dt:enum-married-single-divorced"/> <spouse_name eg:content="dt:string-45" ex:relevant="../married='married'">Spouse name here</spouse_name> </taxpayer>
A bind element will be generated for all leaf element nodes, including "hidden fields". The binding will include any Model
Item Property definitions defined by examploforms attributes from the previous section. If an eg:content attribute is present, it
will be used to assign a type Model Item Property, otherwise the following iconic datatype strings, if present as element
content, will decide the datatype:
A form control will be generated for only leaf element nodes, according to the following rules:
The type of form control generated will be an input, unless one of the following conditions apply:
select1maxLength of over 100 characters, the control will be a textareaAll form controls will have a label taken from the ex:label element, if present, otherwise a default label will be constructed
based on the local name of the element node.
A repeating section will be generated for any element node on which eg:occurs="+" is present. Such elements will generally not
be leaf element nodes; the element content will be repeated.
This example will create a simplified purchase order with repeating line items:
<po>
<to>Company Name</to>
<from>Company Name</from>
<line_item eg:occurs="+">
<part_no ex:label="Part Number">123</part_no>
<desc ex:label="Description">Description</desc>
<price eg:content="xs:decimal">1.23</price>
<quan ex:label="Quantity">1</quan>
<ext_price ex:calculate="../price * ../quan"/>
</line_item>
<total ex:calculate="sum(/po/lineitem/ext_price)"/>
</po>
This project has a Wiki set up at wiki.brainattic.info. Please direct any questions or comments to the comment page here.
This stylesheet (still under development) converts Examploforms instances into XForms+XHTML suitable for rendering in an off-the-shelf XForms engine. Note that not much attention has yet been put into making the resulting forms look terribly attractive.
A CSS stylesheet borrowed from RDDL used to provide the "look-and-feel" of this document, suitable in general for RDDL documents.
Original version of the previous CSS stylesheet on rddl.org.
A running list of things left todo with this project:
Special thanks go to David Montgomery of Netfile who has inspired and funded work on this project, and to Eric van der Vlist who continues to edit the Examplotron specification. Rick Jelliffe came up with Schematron, which Examploforms also has a resemblance toward. Many thanks to the many people that have given me hints, ideas or encouragement.
Non normative list (by chronological order): David Montgomery, Eric van der Vlist, Uche Ogbuji.
Copyright (c) 2004 Brain Attic, L.L.C.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL BRAIN ATTIC, L.L.C. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.