Given a good understanding of what XPath is and how it works, it’s pretty simple to see how it fits into the XForms architecture.
Every use of XPath in XForms involves a context node, usually with the effect of shortening the number of steps needed in the path expression. For example, if the instance data is a simple XHTML document:
<html:html xmlns:html="http://www.w3.org/1999/html"> <html:head> <html:title>Mutant Registration Guidelines</html:title> </html:head> <html:body> <html:p>The White House announced today...</html:p> </html:body> </html:html>
the default context node is the element node named
html:html. Thus, to bind a form control to the
document title, instead of the longer absolute path
/html:html/html:head/html:title, a shorter
html:head/html:title could be used.
The key difference between the two is that absolute paths contain a
leading slash and the name of the root element. Since there can be
only one root element, including its name in every path expressions
isn’t necessary—path expressions
don’t become ambiguous by leaving out what is really
a redundant step along the path.
The default context node can be changed. Any element containing a
binding expressions resets the context node for any child elements.
Binding expressions include the
possibly with the
model attribute, or
bind attribute. Either way, the expression selects a node-set from the instance data, and the first node, ...