Differences
This is from one of the appendices of the XForms 2 spec.
- Expressions
- Uses XPath n, instead of XPath 1; allows amongst other things atomic
values and typed values
- Attribute Value Templates (AVTs) allow calculated values to be used
in attributes, enabling the deprecation of many child elements
- Custom functions and variables have been added
- New functions: valid() relevant() readonly() required() case()
serialize() seconds-from-epoch() bind() element() attribute() parse()
eval() eval-in-context() location-uri() location-param() uri-scheme()
uri-scheme-specific-part() uri-authority() uri-user-info() uri-host()
uri-port() uri-path() uri-query() uri-fragment() uri-param-names()
uri-param-values()
- Data
- External instance fallback: if @src on <instance/> fails, the
instance is initialised with the inline content.
- Multiple MIPs of the same property allowed on one node.
- New whitespace MIP defines how space is treated in values
- json, csv and other external instance data formats are supported
- slight change in how nested binds select items.
- Types
- The definition of validity has been slightly changed to allow empty
non-required values to be considered valid. Consequently, the XForms
datatypes no longer all include empty as a possible value.
- better email type
- new types:
- two IRI types
- iemail type
- telephone number type
- HTMLFragment type
- Controls
- The @nodeset attribute is deprecated in favour of @ref everywhere
- a new dialog element
- a new <control/> element for embedding an XForm in an XForm,
plus actions <return/>, and <renew/>
- repeat has an @indexref attribute
- <repeat appearance='minimal' .../> <group
appearance='minimal' ...>
- switch has a @caseref attribute
- an item of a select1 can be deselected
- label, hint, help, alert
- attributes have been added as alternatives to the child
elements
- properties have been added to the bind element
- label elements/attributes are consequently now optional on
controls
- Unification of how output, label, help, hint, and alert work.
- No linking on <help/>
- @appearance on <alert> (erratum)
- Actions
- @iterate has been added to actions
- <update/>
- <cancel/> action added
- <insert/> no longer makes values of type ID unique
- <insert/> and <delete/> indexes must be in range.
- All actions that have an IDREF attribute now dispatch an
xforms-action-error if that attribute does not identify a (suitable)
element.
- ability to call script (such as JavaScript) from actions, including
passing parameters
- <reset instance="id"/> and <retain/>
- <return/>, and <renew/> to go with <control/>
element.
- Small change in the order of evaluation of <load/> attributes
- Events
- add properties to dispatched events
- xforms-action-warning event added
- xforms-submit-ready event added
- xforms-rebuild, xforms-revalculate, xforms-revalidate,
xforms-refresh, and xforms-reset events deprecated in favour of the
respective actions
- xforms-submit-serialize deprecated
- event handlers are no longer disabled when their associated controls
are disabled.
- events now conditionally cancellable with <cancel/> action
- Submission
- @response-mediatype overrides incoming mediatype
- get is default submission method
- @nonrelevant replaces @relevant, with new options
- @value available for providing data to be submitted
- Other
- <form> element as root element if one is needed
- p3ptype has been deprecated
Differences
Lots of small changes, like new types, new functions.
Doesn't specify which version of XPath is used any more, but must be >
1
AVTs
These have been present in processors for a long time.
<output class="{xpath expr}" ref="..."/>
Label (etc) attributes
@label @alert @hint @help
as alternatives
<input ref="h" label="height" alert="Must be positive"/>
Fallback on instance
<instance src="saved.xml">
<game xmlns="">
<score>0</score>
</game>
</instance>
You can already do this, with submissions and events, but it's much more
work.
Event
New event: xforms-refresh-done
Similar to xforms-ready
: Tells you when the processor is idle.
Good for generation-based programs, such as Game of Life.
whitespace property
<bind ref="email" whitespace="trim"/>
<bind ref="cc" whitespace="remove"/>
<bind ref="name" whitespace="collapse"/>
- preserve: all whitespace is preserved (default)
- remove: all whitespace is removed,
- trim: all whitespace from the beginning and end of the string is
removed,
- collapse: each occurrence of multiple whitespace is replaced with a
single space character
- normalize: a combination of 'trim' and 'collapse'.
reset and retain instances
It's now possible to preserve the state of an instance, and restore it
later.
<form> element
XForms has never had a root element, since it was always designed to be
embedded in other languages.
Now it has one, for stand-alone processors.
<control/>
Embeds an XForm in another, with communication
<control label="before" resource="histogram.xf" ref="before"/>
<control label="after" resource="histogram.xf" ref="after"/>
Acts just like a regular control, with label
,
alert
, etc.
@ref
data is shared between the two, if one changes the data,
the other sees the change.
In the embedded control
<shared ref="data" initial="external"/>
specifies the shared content, and where the initial values come from.
Events can be sent between the two.
If a form is not embedded, it performs normally.