Steven Pemberton, W3C/CWI
Version date: 2021-02-05
Blue links are to the spec, red links to within this document.
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)?, version (xforms:versionList) | (instance | schema | submission | bind | Action)* |
instance | src(anyURI)?, resource (xsd: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))?, 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)?, targetref (XPath)?, separator(';' | '&')?, includenamespaceprefixes(NMTOKENS)? | (resource | method | header)*, Action* |
resource | value (XPath) | PCDATA |
method | value (XPath) | PCDATA |
header | nodeset (XPath), combine("append"|"prepend"|"replace") | name, value+ |
name | value(XPath) | PCDATA |
value | value(XPath) | PCDATA |
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 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?, src(anyURI)?, 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 |
Attribute set | Attributes |
---|---|
Conditional | if(XPath), while(XPath) |
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 |
Type (all in the XForms namespace) | 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 | |
dayTimeDuration yearMonthDuration | Durations |
listItem listItems | Type for <select> and <select1> |
Email address | |
card-number | Credit card (etc) number |
See XPath Axes
Axis | Shortcut |
---|---|
child |
(empty) |
parent | .. |
self | . |
attribute | @ |
ancestor | |
ancestor-or-self | |
descendant | |
descendant-or-self | // |
preceding-sibling | |
following-sibling | |
preceding | |
following | |
namespace |
| | 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, otherwise the second |
compare | string, string | number | Is the first argument lexicographically less than, equal to, 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 | node-set | number | The number of non-empty nodes |
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 | The named property of the current event |
hmac | string, string, string, string? | The second argument encrypted according to the algorithm named in the third using the key in the first argument, and encoded according to the fourth (default base64) | |
id | object, nodeset? | nodeset | The nodes in the second argument that have the IDREFs in the first. |
if | boolean, string, string | string | Conditional |
index | string | number | The index of the repeat with the id identified by the parameter. |
instance | string | node-set | Locate instance |
is-card-number | string | boolean | If 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 UTC date and time |
power | number, number | number | The first argument raised to the power of the second |
property | string | string | XForms feature value |
random | boolean | number | A random number between zero and 1 |
seconds | string | number | Seconds in period |
seconds-from-dateTime | string | number | Seconds since epoch (1970) |
seconds-to-dateTime | number | string | The date and time so many seconds since the epoch (1970) |
XPath functions | |||
Function | Arguments | Returns | Description |
boolean | object | boolean | Type conversion |
ceiling | number | number | ceiling(3.1) = 4; ceiling(3.9) = 4 |
concat | string, string, string* | string | Concatenate strings |
contains | string, string | boolean | Whether the first argument contains the second as a substring |
count | nodeset | number | The number of nodes |
false | - | boolean | |
floor | number | number | floor(3.1) = 3; floor(3.9) = 3 |
id | - | objectnodeset | The node(s) matching the supplied id(s) |
lang | string | boolean | Whether the context node is defined as being in the given language. |
local-name | nodeset? | string | The un-namespaced name of the node |
last | - | number | The last position in the context |
name | nodeset? | string | The namespaced name of the node |
namespace-uri | nodeset? | string | The namespace URI of the node |
normalize-space | string? | string | Leading and trailing whitespace stripped, all others reduced to a single space. |
not | boolean | boolean | Boolean inversion |
number | object? | number | Type conversion |
position | - | number | The current position in the context |
round | number | number | round(3.1) = 3; round(3.9) = 4 |
starts-with | string, string | boolean | Whether the first argument starts with the second |
string | object? | string | Convert to string |
string-length | string? | number | The length of the argument in characters |
substring | string, number, number? | string | The first argument from the position of the second, of length the third. |
substring-after | string, string | string | The first string after the first occurrence of the second. substring-after("2020-09-23", "-") = 09-23 |
substring-before | string, string | string | The first string up to the first occurrence of the second. substring-before("2020-09-23", "-") = 2020 |
sum | nodeset | number | The numerical sum of the nodes. |
translate | string, string, string | string | The first argument with all occurrences of characters in the second replaced by the character at the same position in the third, or deleted if there is no corresponding character. |
true | - | boolean |
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") |
Event | Cancel | Bubbles | Target | Context | ||
---|---|---|---|---|---|---|
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> | submission-body | node-set | If non-empty, used in the submission instead of the default serialization. |
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> | inserted-nodes | node-set | The instance data node or nodes inserted. |
origin-nodes | node-set | The instance data nodes referenced by the insert action's origin attribute if present, or the empty nodeset if not present. | ||||
insert-location-node | node-set | The insert location node as defined by the insert action. | ||||
position | string | The insert position, before or after. | ||||
xforms-delete | N | Y | <instance> | deleted-nodes | node-set | The instance data node or nodes deleted. Note that these nodes are no longer referenced by their parents. |
delete-location | number | The delete location as defined by the delete action, or NaN if there is no delete location. | ||||
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> | resource-uri | string | The submission resource URI that succeeded (xsd:anyURI) |
response-status-code | number | The protocol return code of the success response, or NaN if the
submission did not receive a success response. |
||||
response-headers | node-set | Zero or more elements, each one representing a content header in the success response received by the submission. The returned node-set is empty if the submission did not receive a response or if there were no headers. Each element has a local name of header with no namespace URI and two child elements, name and value, whose string contents are the name and value of the header, respectively. | ||||
response-reason-phrase | string | The protocol response reason phrase of the success response. The string is empty if the submission did not receive a response or if the response did not contain a reason phrase. | ||||
Error Notifications | ||||||
xforms-binding-exception | N | Y | element with the binding | |||
xforms-link-exception | N | Y | <model> | resource-uri | string | The URI associated with the failed link (xsd:anyURI) |
xforms-compute-exception | N | Y | <model> | error-message | string | An implementation-specific string that should contain the expression being processed when the exception was detected. |
xforms-version-exception | N | Y | default <model> | error-information | string | An implementation-specific error string |
xforms-output-error | N | Y | <output> | |||
xforms-submit-error | N | Y | <submission> | error-type | string | One of the following: submission-in-progress, no-data, validation-error, parse-error, resource-error, target-error. |
resource-uri | string | The submission resource URI that failed (xsd:anyURI) | ||||
response-status-code | number | The protocol return code of the error response, or NaN if the failed
submission did not receive an error response. |
||||
response-headers | node-set | Zero or more elements, each one representing a content header in the error response received by a failed submission. The returned node-set is empty if the failed submission did not receive an error response or if there were no headers. Each element has a local name of header with no namespace URI and two child elements, name and value, whose string contents are the name and value of the header, respectively. | ||||
response-reason-phrase | string | The protocol response reason phrase of the error response. The string is empty if the failed submission did not receive an error response or if the error response did not contain a reason phrase. | ||||
response-body | object (string or node-set) | When the error response specifies an XML media type as defined by [RFC 3023], the response body is parsed into an XML document and the root element of the document is returned. If the parse fails, or if the error response specifies a text media type (starting with text/), then the response body is returned as a string. Otherwise, an empty string is returned. |
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 |
Construct |
---|
getInstanceDocument() |
rebuild() |
recalculate() |
rebuild() |
refresh() |