currentAdded by IBM on October 10, 2012 | Version 1 (Original)
|Returns the nodeset that is currently providing the context for the XPath expression. This is useful when you need to reset the context in the middle of an XPath expression.
Returns Returns the context nodeset.
Example The following model contains two data instances are used to create a form that converts currencies. The first instance contains the user-supplied information, including the amount and the currency they want to convert to. The second instance contains information about exchange rates.
The following bind populates the <convertedAmount> element based on the data provided by the user and the exchange rate:
<xforms:instance xmlns="" id="convTable">
<convTable date="20040212" currency="cdn">
The bind multiplies the <amount> by the proper conversion rate. The context node for this bind is established by the nodeset attribute as the <convertedAmount> element in the first instance. This means that all XPath is evaluated relative to this node. However, to determine the conversion rate we must refer to the second instance. To do this, we use the instance function to retrieve the second instance, and then check the <rate> elements in that instance.
Next, we find the correct rate by do a string comparison between the currency attribute of each <rate> element and the contents of the <currency> element in the first instance. However, the <currency> element is in the first instance, and we have already changed our context to the second instance by using the instance function. So, to refer to the <currency> element in the first instance we must use the current function, as shown:
Using the current function resets our context to the <convertedAmount> node, which was established as our context node by the nodeset attribute on the bind. So this expression evaluates to:
<bind nodeset="convertedAmount" calculate="../amount *
This retrieves the contents of the currency node in the first data element. This value is then compared to the currency attribute on each <rate> element until the correct <rate> element is located.