The evaluation context

Mark Birbeck's picture

XForms uses XPath expressions in many places, and it is important as an author to understand how these expressions are evaluated. Perhaps the most important concept is that of the evaluation context.

When an XPath expression is evaluated, the processor needs to know both the model and the instance against which to evaluate the expression. Since all expressions are evaluated in some context then it should always be possible to work out the meaning of even short expressions such as "/".

To illustrate the context rules, we'll begin with the simplest situation, when the form being processed has only one model and one instance:

  <xf:model id="mdl">
    <xf:instance id="inst">
      <a xmlns="">
        <b />
      </a>
    </xf:instance>
  </xf:model>