From W3C XForms Group Wiki (Public)
XPath 2.0 in XForms
This feature will add XPath 2.0 support to XForms. An editor's draft of the ongoing work is available at http://www.w3.org/MarkUp/Forms/specs/XForms1.2/modules/xpath20/index-all.html
This wiki page gives an overview of why certain decisions were made and what issues are still open.
Dependencies on other XForms 1.2 work
- add select attribute to elements that support nodeset attribute and the output element (can't find a wiki page for this)
- select: allows a sequence of zero or more nodes or atomic values, i.e. item()* (allows: multiple occurrences of the same node, nodes don't need to be in document order)
xpath-version attribute on model element
- We will add an xpath-version attribute to the model element (supported values are 1.0 and 2.0, default value is 1.0 for the default model and the value of the default model for non-default models)
- The XForms processor will choose the XPath version that is used based on its default model
- When a non default model is requesting a conflicting xpath-version the XForms Processor will terminate processing after dispatching the event xpath-version-exception to the default model.
XForms Function Library
The XForms Function Library defines additional functions that are useful for creating forms. The functions will be made available in the XForms namespace. When the XPath version on the model is 1.0 or omitted the functions will be made also available in the default function namespaceXP. Additionally all functions defined as built-in function and the operators in [Functions and Operators] are also available in XForms.
Note: An implementation may choose to make these additional function also available in the standard function namespace when the XPath version on the model is not 1.0 if he has a good reason for it (e.g.: Backwards compatibility).
Erik's note: seconds-from-dateTime() is defined in both XForms 1.0/1.1 and XPath 2.0, in incompatible ways. This needs a resolution.
|XForms 1.1 definition||XForms 1.2 definition|
|boolean boolean-from-string(string)||xs:boolean boolean-from-string(xs:string)|
|boolean is-card-number(string?)||xs:boolean is-card-number(xs:string?)|
|number avg(node-set)||numeric avg(xs:anyAtomicType*)|
|number min(node-set)||numeric min(xs:anyAtomicType*)|
|number max(node-set)||numeric max(xs:anyAtomicType*)|
|number count-non-empty(node-set)||xs:integer count-non-empty(node()*)|
|number index(string)||xs:integer index(xs:string)|
|number power(number, number)||numeric power(numeric, numeric)|
|number random(boolean?)||numeric random(xs:boolean?)|
|number compare(string, string)||xs:integer compare(xs:string, xs:string)|
|string if(boolean, string, string)|
|string property(string)||xs:string property(xs:string)|
|string digest(string, string, string?)||xs:string digest(xs:string, xs:string, xs:string?)|
|string hmac(string, string, string?)||xs:string hmac(xs:string, xs:string, xs:string?)|
|string local-date()||xs:date local-date()|
|string local-dateTime()||xs:dateTime local-dateTime()|
|string now()||xs:string now()|
|number days-from-date(string)||xs:integer days-from-date(xs:string)|
|string days-to-date(number)||xs:date days-to-date(numeric)|
|number seconds-from-dateTime(string)||xs:integer seconds-from-dateTime(xs:string)|
|string seconds-to-dateTime(number)||xs:string seconds-to-dateTime(numeric)|
|string adjust-dateTime-to-timezone(string)||xs:dateTime adjust-dateTime-to-timezone(xs:dateTime) (requires xs:dateTime constructor to convert xs:string to xs:dateTime in form)|
|number seconds(string)||xs:integer seconds(xs:string)|
|number months(string)||xs:integer months(xs:string)|
|node-set instance(string?)||node() instance(xs:string?)|
|node-set current()||item() current()|
|node-set id(object, node-set?)||element()* id(xs:string*, node()*)|
|element()* id(element()*, node()*)|
|node-set context()||item() context()|
|object choose(boolean, object, object)||item()* choose(xs:boolean, item()*, item()*)|
|object event(string)||item()* event(xs:string)|
Conflicting functions in XForms 1.1 vs XPath 2.0
There aren't that many conflicting functions, the one I found are sum, avg, min and max. These functions return NaN in XForms if the result can't be computed. In XPath 2.0 an empty sequence is returned if an empty sequence is provided as argument, in all other cases were the result couldn't be computed a type error is raised.
Dynamic Context: Current date and time
The current date and time represents an implementation-dependent point in time during processing of an expression. Do we want to define when the date/time should be the same (e.g.: between refreshes). What do we do with event handlers triggered by a delayed dispatch?
Update 3.2.2 Initializing the Dynamic Context
See http://www.w3.org/TR/xslt20/#xpath-dynamic-context for text in XSLT
XPath 2.0 functions that (may) introduce problems
- dependency problems
- Node creation problems (which will be solved if we say that all nodes that aren't part of an instance behave as if they have read-only MIP attached which can't be removed)