STATUS: as of 2011-02, an implementation of XPath dependencies in the UI and in the model is in place in the XForms engine. You can enable it with a property.
How the implementation worksSaxon PathmapThe implementation leverages the Saxon PathMap implementation:
Orbeon uses a slightly modified version of PathMap as the built-in Saxon one did not support some functionality.
XPathAnalysisA core class is XPathAnalysis, which is passed an expression (String or Expression), and extracts:
For example: instance('people')/person[../age ge 21] returns:
Analyzed expressions are always rooted at an instance. Paths are represented in a canonical way:
Bindings and valuesA control can have a binding and/or a value.
Consider this instance:
Consider a top-level group:
The binding is a path relative to something: the in-scope XPath evaluation context. Say this is
instance('people') .So for each binding / value, the analysis for the context and for the in-scope variables is made available.
Here, first, an XPathAnalysis is computed for
instance('people') .Then, the expression person[../age ge 21] is analyzed:
Now what woud cause the binding for my-group to require an update? Clearly, either:
Currently, any structural change in a model invalidates all bindings and values touching that model. (We can do much better in the future.)
The value change is handled easily. If, between two refreshes, any changes is done to the value of the node instance('foo')/age, the binding needs to be reevaluated. Otherwise, no evaluation is needed.
Note that even if the value of node instance('foo')/person changes, the binding need not change.
The algorithm to determine if a binding must change is:
For a value, the algorithm is the same except that returnable paths are also checked.
Model binds and MIPsModel binds and MIPs are supported as well. The purpose is:
Expressions supportedNot every XPath expression can be supported, especially if nothing is known about the XML document.
The following is easy to support:
Parent / ancestor axes can be handled in some cases:
In general, the following is not supported:
Implementation notesMain filesThe implementation is partially done in Scala:
Static XForms document initializationProcessing order during static XForms document initialization:
Next steps
March 2010 experiment - notesStarting point
ExperimentThe idea of the experiment is to determine if, in a short amount of development time, it is possible to develop a small dependency system that works on this use case. Simple UI example:
This is how things are meant to work:
Phase 1 limitations:
Implementation notes
|