img

XForms Quick Reference

Steven Pemberton, W3C/CWI

Version date: 2006-03-23

Namespaces

Name Namespace
XForms http://www.w3.org/2002/xforms
Events (ev) http://www.w3.org/2001/xml-events
Schema (xsd)
http://www.w3.org/2001/XMLSchema
Schema for instances (xsi) http://www.w3.org/2001/XMLSchema-instance
XHTML http://www.w3.org/1999/xhtml

Model

Element Attributes Content Model
model Events?, functions(QNameList)?, schema(list of anyURI)? (instance | schema | submission | bind | Action)*
instance src(anyURI)? (Any)
bind nodeset(XPath), relevant(XPath)?, required(XPath)?, readonly(XPath)?, constraint(XPath)?, calculate(XPath)?, type(QName)?, p3ptype(string)? (bind)*
submission Events?, (ref(XPath) | bind(IDREF))?, action(anyURI), method("post"|"get"|"put"|"form-data-post"|"urlencoded-post"), version(NMTOKEN)?, indent(boolean)?, mediatype(string)?, encoding(string)?, omit-xml-declaration(boolean)?, standalone(boolean)?, cdata-section-elements(QNameList)?, replace("all"|"instance"|"none"|qname-but-not-ncname)?, instance (xsd:IDREF), separator(';' | '&')?, includenamespaceprefixes(NMTOKENS)? Action*

Submission methods

Method Serialization Schemes
post xml http(s) mailto
put xml http(s) file
get url encoded http(s) file
urlencoded-post url encoded http(s) mailto
form-data-post multipart form data http(s) mailto
multipart-post multipart related http(s) mailto

Form Controls

Element Attributes Content Model
input Appearance?, Binding, inputmode(string)?, incremental(boolean)? label, (UI Common)*
secret Appearance?, Binding, inputmode(string)?, incremental(boolean)? label, (UI Common)*
textarea Appearance?, Binding, inputmode(string)?, incremental(boolean)? label, (UI Common)*
output Appearance?, (Binding | value(XPath)) label?
upload Appearance?, Binding, mediatype(string), incremental(boolean)? label, filename?, mediatype?, (UI Common)*
range Appearance?, Binding, start(string)?, end(string)?, step(string)?, incremental(boolean)? label, (UI Common)*
trigger Appearance, Binding? label, (UI Common)*
submit Appearance, Binding?, submission(IDREF) label, (UI Common)*
select Appearance, Binding, selection("open" | "closed")?, incremental(boolean)? label, (List UI Common)+, (UI Common)*
select1 Appearance, Binding, selection("open" | "closed")?, incremental(boolean)? label, (List UI Common)+, (UI Common)*

Switch, repeat, group

Element Attributes Content Model
switch Appearance?, Binding? case+
repeat Appearance?, Multibinding, startindex(positiveInteger)?, number(nonNegativeInteger)? ((Form Controls) | group | repeat)*
group Appearance, Binding? label?, ((Form Controls)|group|switch|repeat|(UI Common))*
(various) repeat-nodeset(XPath), repeat-model(IDREF), repeat-bind(IDREF), repeat-startindex(positiveInteger), repeat-number(nonNegativeInteger) N/A
Forms Control Content Sets
Content Set Attributes Content Model
UI Common - help|hint|alert|Action
List UI Common - choices|item|itemset
UI Inline - output
case selected(boolean)? label?, ((Form Controls)|group|switch|repeat)*
choices - label?, (List UI Common)+
item - label, value, (UI Common)*
itemset Multibinding label, (value|copy), (UI Common)*
filename Binding -
mediatype Binding -
value Binding? (PCDATA|ANY)*
copy Binding? -
label Binding?, src(anyURI)? (PCDATA|(UI Inline))*
help Binding?, src(anyURI)? (PCDATA|(UI Inline))*
hint Binding?, src(anyURI)? (PCDATA|(UI Inline))*
alert Binding?, src(anyURI)? (PCDATA|(UI Inline))*
Attribute Sets
Attribute set Attributes
Appearance appearance("full"|"compact"|"minimal")
Binding (ref(XPath), model(IDREF)?) | bind(IDREF)
Multibinding (nodeset(XPath), model(IDREF)?) | bind(IDREF)

Actions

Element Attributes Content Model
action Events (Action)+
delete Events, Multibinding, at(XPath) EMPTY
dispatch Events, name(NMTOKEN), target(IDREF), bubbles(boolean)?, cancelable(boolean)? EMPTY
insert Events, Multibinding, at(XPath), position("before"|"after") EMPTY
load Events, Binding?, resource(anyURI), show("new" | "replace")? EMPTY
message Events, Binding?, src(anyURI)?, level("ephemeral" | "modeless" | "modal") (PCDATA|UI Inline)*
rebuild Events, model(IDREF) EMPTY
recalculate Events, model(IDREF) EMPTY
refresh Events, model(IDREF) EMPTY
reset Events, model(IDREF) EMPTY
revalidate Events, model(IDREF) EMPTY
send Events, submission(IDREF) EMPTY
setfocus Events, control(IDREF) EMPTY
setindex Events, repeat(IDREF), index(XPath) EMPTY
setvalue Events, Binding, value(XPath)? PCDATA
toggle Events, case(IDREF) EMPTY

Types

Type (xsd: unless otherwise indicated) Description
dateTime time date gYearMonth gYear gMonthDay gDay gMonth Dates and times
string
boolean
base64Binary hexBinary
float decimal double
anyURI
QName
normalizedString Multiple whitespace replaced with a single space
token
language Language code
Name NCName
ID IDREF IDREFS NMTOKEN NMTOKENS
integer nonPositiveInteger negativeInteger long int short byte nonNegativeInteger unsignedLong unsignedInt unsignedShort unsignedByte positiveInteger
xforms:dayTimeDuration xforms:yearMonthDuration Durations
xforms:listItem xforms:listItems Type for <select>

XPath Axes

Axis Shortcut
child
(empty)
parent ..
self .
attribute @
ancestor
ancestor-or-self
descendant
descendant-or-self //
preceding-sibling
following-sibling
preceding
following
namespace
XPath Operators
| Union
* Wildcard
[] Predicate
+ - * div mod Arithmetic
= < <= > >= != and or Boolean

XForms functions

Function Arguments Returns Description
avg node-set number Average
boolean-from-string string boolean Type conversion
count-non-empty node-set number Count non-empty
days-from-date string number Days in epoch
if boolean, string, string string Conditional
index string number Repeat index
instance string node-set Locate instance
max node-set number Maximum
min node-set number Minimum
months string number Months in period
now - string Current time
property string string Feature value
seconds string number Seconds in period
seconds-from-dateTime string number Seconds in epoch

XPath functions

Function Arguments Returns
last - number
position - number
count nodeset number
id - objectnodeset
local-name nodeset? string
namespace-uri nodeset? string
name nodeset? string
string object? string
concat string, string, string* string
starts-with string, string boolean
contains string, string boolean
substring-before string, string string
substring-after string, string string
substring string, number, number? string
string-length string? number
normalize-space string? string
translate
string, string, string string
boolean object boolean
not boolean boolean
true - boolean
false - boolean
lang string boolean
number object? number
sum nodeset number
floor number number
ceiling number number
round number number

Event attributes

Attribute Type
ev:observer
IDREF
ev:target IDREF
ev:event NMTOKEN
ev:handler IDREF
ev:phase ("capture" | "default")
ev:propagate ("stop" | "continue")
ev:defaultAction ("cancel" | "perform")

XForms events

Event Cancel Bubbles Target
Initialization Events
xforms-model-construct N Y <model>
xforms-model-construct-done N Y <model>
xforms-ready N Y <model>
xforms-model-destruct N N <model>
Processing Events
xforms-rebuild Y Y <model>
xforms-recalculate Y Y <model>
xforms-revalidate Y Y <model>
xforms-refresh Y Y <model>
Interaction Events
xforms-previous Y N <control>
xforms-next Y N <control>
xforms-focus Y N <control>
xforms-help Y Y <control>
xforms-hint Y Y <control>
xforms-reset Y Y <model>
xforms-submit Y Y <submission>
DOMActivate Y Y <control>
Notification Events
DOMFocusIn N Y <control>
DOMFocusOut N Y <control>
xforms-value-changed N Y <control>
xforms-select N Y <item>, <case> or <itemset>
xforms-deselect N Y <item>, <case> or <itemset>
xforms-scroll-first N Y <repeat>
xforms-scroll-last N Y <repeat>
xforms-insert N Y <instance>
xforms-delete N Y <instance>
xforms-valid N Y <control>
xforms-invalid N Y <control>
xforms-in-range N Y <control>
xforms-out-of-range N Y <control>
xforms-readonly N Y <control>
xforms-readwrite N Y <control>
xforms-required N Y <control>
xforms-optional N Y <control>
xforms-enabled N Y <control>
xforms-disabled N Y <control>
xforms-submit-done N Y <submission>
xforms-submit-error N Y <submission>
Error Notifications
xforms-binding-exception N Y <bind>
xforms-link-exception N Y <model>
xforms-link-error N Y <model>
xforms-compute-exception N Y <model>

CSS

Selector Matches
:valid and :invalid datatype validity and 'constraint' bindings
:in-range and :out-of-range range, select1 and select controls where value doesn't match
:required and :optional 'required' bindings
:read-only and :read-write 'read-only' bindings
:enabled and :disabled 'relevant' bindings
::value The part of a control where the value is displayed/typed in
::choices The items part of a select1 or select
::repeat-item Any row in a repeat
::repeat-index The 'current' repeat row

DOM

Construct
getInstanceDocument()
rebuild()
recalculate()
rebuild()
refresh()