Using the getValue and setValue from JavaScript
ORBEON.xforms.Document.setValue("foo", 42);
Value of foo:
42
42
43
43
44
44
45
45
46
46
47
47
Value of bar:
Increment foo with JavaScript
var fooValue = ORBEON.xforms.Document.getValue("foo");
ORBEON.xforms.Document.setValue("foo", Number(fooValue) + 1);