XForms 1.1 Quick Reference

Steven Pemberton, W3C/CWI

Version date: 2010-11-29


Name Namespace
Events (ev)
Schema (xsd)
Schema for instances (xsi)


Element Attributes Content Model
model Events?, functions(QNameList)?, schema(list of anyURI)?, version (versionList)? (instance | schema | submission | bind | Action)*
instance src(anyURI)?, resource (anyURI)? (ANY)
bind nodeset(XPath), relevant(XPath)?, required(XPath)?, readonly(XPath)?, constraint(XPath)?, calculate(XPath)?, type(QName)?, p3ptype(string)? (bind)*

Events?, (ref(XPath) | bind(IDREF))?, resource (anyURI), action(anyURI)?, mode ("asynchronous"|"synchronous")?, method("post"|"get"|"put"|"delete"|"multipart-post"|"form-data-post"|"urlencoded-post"|Any other NCName|QNameButNotNCName)?, validate (boolean)?, relevant (boolean)?, serialization ("application/xml"|"application/x-www-form-urlencoded"|"multipart/related"|"multipart/form-data"|"none")?, version(NMTOKEN)?, indent(boolean)?, mediatype(string)?, encoding(string)?, omit-xml-declaration(boolean)?, standalone(boolean)?, cdata-section-elements(QNameList)?, replace("all"|"instance"|"text"|"none"|qname-but-not-ncname)?, instance(IDREF)?, separator(';' | '&')?, includenamespaceprefixes(NMTOKENS)?

(resource | method | header)*, Action*
resource value(XPath)? PCDATA
method value(XPath)? PCDATA
name value(XPath)? PCDATA
value value(XPath)? PCDATA

Submission methods

Method Serialization Schemes
post xml http(s) mailto
put xml http(s) file
get url encoded http(s) file
delete 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)), mediatype(string)? label?, mediatype?, (UI Common)*
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 | switch | repeat | Action)*
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 Content - output
case selected(boolean)? label?, ((Form Controls) | group | switch | repeat |Action)*
choices - label?, (List UI Common)+
item - label, value, (UI Common)*
itemset Multibinding label, (value|copy), (UI Common)*
filename Binding -
mediatype Binding, value(XPath){value only when parent is <output>} -
value Binding? (PCDATA | ANY)*
copy Binding? -
label Binding? (PCDATA | output)*
help Binding? (PCDATA | output)*
hint Binding? (PCDATA | output)*
alert Binding? (PCDATA | output)*
Attribute Sets
Attribute set Attributes
Appearance appearance("full" | "compact" | "minimal")
Binding (ref(XPath), model(IDREF)?) | bind(IDREF)
Multibinding (nodeset(XPath), model(IDREF)?) | bind(IDREF)


Element Attributes Content Model
action Events, Conditional (Action)*
delete Events,Conditional, Multibinding, context (XPath), at(XPath) EMPTY
dispatch Events, Conditional, name(NMTOKEN), targetid(IDREF), delay(nonNegativeInteger)?, bubbles(boolean)?, cancelable(boolean)? name?, targetid?, delay? [in any order]
insert Events,Conditional, Multibinding, context(XPath)?, at(XPath)?, position("before"|"after")?, origin(XPath)? EMPTY
load Events, Conditional, Binding?, resource(anyURI), show("new" | "replace")? resource?
message Events, Conditional, Binding?, level("ephemeral" | "modeless" | "modal") (PCDATA | output)*
rebuild Events, Conditional, model(IDREF) EMPTY
recalculate Events, Conditional, model(IDREF) EMPTY
refresh Events, Conditional, model(IDREF) EMPTY
reset Events, Conditional, model(IDREF) EMPTY
revalidate Events, Conditional, model(IDREF) EMPTY
send Events, Conditional, submission(IDREF) EMPTY
setfocus Events, Conditional, control(IDREF) control?
setindex Events, Conditional, repeat(IDREF), index(XPath) EMPTY
setvalue Events, Conditional, Binding, value(XPath)? PCDATA
toggle Events, Conditional, case(IDREF)? case?
case value(string)? PCDATA
control value(XPath)? PCDATA
resource value(XPath)? PCDATA
delay value(XPath)? PCDATA
targetid value(XPath)? PCDATA
name value(XPath)? PCDATA
Attribute Set
Attribute set Attributes
Conditional if(XPath) | while(XPath)


Type (all in the XForms namespace, derived as necessary from XSD types, in which case they also allow empty content) Description
dateTime time date gYearMonth gYear gMonthDay gDay gMonth Dates and times
base64Binary hexBinary
float decimal double
normalizedString Multiple whitespace replaced with a single space
language Language code
Name NCName
integer nonPositiveInteger negativeInteger long int short byte nonNegativeInteger unsignedLong unsignedInt unsignedShort unsignedByte positiveInteger
dayTimeDuration yearMonthDuration Durations
listItem listItems

Type for <select> and <select1>

email Email address
card-number Credit card (etc) number

XPath Axes

See XPath Axes

Axis Shortcut
parent ..
self .
attribute @
descendant-or-self //
XPath Operators
| Union
* Wildcard
[] Predicate
+ - * div mod Arithmetic
= < <= > >= != and or Boolean

XForms functions

Function Arguments Returns Description
adjust-dateTime-to-timezone string string Date and time converted to the local time zone
avg node-set number Average
boolean-from-string string boolean Type conversion
choose boolean, object, object object The first object if the boolean is true, and otherwise the second
compare string, string number Whether the first argument is lexicographically less than, equal, or greater than the second
context - nodeset The context node of the nearest ancestor element of the node containing the XPath expression
count-non-empty nodeset number How many non-empty nodes there are in the nodeset.
current - nodeset The context node used for this evaluation
days-from-date string number Days since epoch (1970)
days-to-date number string The date so many days after the epoch (1970)
digest string, string, string? string The first argument encrypted according to the algorithm named in the second, and encoded according to the third.
event string object A property of the current event of an action
hmac string, string, string, string? The second argument encrypted according to the algorithm named in the second using the key in the first argument, and encodes according to the third.
id object, nodeset? nodeset The set of nodes in the second argument that have the IDREFs in the first.
if boolean, string, string string Conditional
index string number Repeat index
instance string node-set Locate instance
is-card-number string boolean Whether the card number is a valid card number
local-date - string Date in current time zone
local-dateTime - string Date and time in current time zone
max node-set number Maximum
min node-set number Minimum
months string number Months in period
now - string Current date and time
power number, number number The first argument raised to the power of the second argument
property string string Feature value
random boolean number A random number
seconds string number Seconds in period
seconds-from-dateTime string number Seconds since epoch
seconds-to-dateTime number string The date and time so many seconds since the epoch (1970)

XPath functions

Function Arguments Returns Description
last - number
position - number
count nodeset number
id object nodeset
local-name nodeset? string
namespace-uri nodeset? string
name nodeset? string
string object? string Type conversion
concat string, string, string* string Concatenate strings
starts-with string, string boolean Whether the first argument starts with the second argument
contains string, string boolean Whether the first argument contains the second argument
substring-before string, string string substring-before("1999/04/01","/") returns "1999"
substring-after string, string string substring-after("1999/04/01","/") returns "04/01"
substring string, number, number? string substring("abcdef", 2, 3)="bcd"; substring("abcdef", 4)="def"
string-length string? number
normalize-space string? string
string, string, string string translate("bar","abc","ABC")="BAr"
boolean object boolean Type conversion
not boolean boolean
true - boolean
false - boolean
lang string boolean Whether the context node has been declared to be of the given language.
number object? number Type conversion
sum nodeset number
floor number number
ceiling number number
round number number

Event attributes

Attribute Type
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>
xforms-reset 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-submit Y Y <submission>
xforms-submit-serialize N Y <submission>
Notification Events
DOMActivate Y Y control
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>
Error Notifications
xforms-binding-exception N Y element with the binding
xforms-link-exception N Y <model>
xforms-compute-exception N Y <model>
xforms-version-exception N Y default <model>
xforms-output-error N Y <output>
xforms-submit-error N Y <submission>


See XForms and Styling

Selector Matches
:valid and :invalid datatype validity and 'constraint' bindings
:in-range and :out-of-range range, select1 and select controls, whether value matches
: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