Expand description
rxeval — evaluate ODK/OpenRosa XForms logic.
The third piece beside rxform
(spreadsheet → XForm) and rxdata (submission → typed data): the rules
a form carries — relevant, constraint, required, calculate — are
written in XPath, and until something evaluates them a server can only
take a device’s word for what it collected.
One engine, three places. On the server it checks what arrived. Compiled to WebAssembly it drives a web form. Bound from R it lets a questionnaire’s logic be exercised before anyone goes to the field. Enketo’s engine is browser-only JavaScript and JavaRosa’s is JVM-only; neither travels.
What an expression can do. These are XForms expressions, not a
scripting language: the grammar is XPath 1.0, the only inputs are the
instance tree and the environment handed in, and evaluation performs no
I/O, spawns nothing and cannot reach the host. A hostile expression can
waste time or return a wrong answer; it cannot escape. eval_str is
named for XPath evaluation, and shares nothing with the eval of
interpreted languages.
Nothing here guesses. An expression this crate does not understand is
an error, never a default. A form engine that returns false for a
relevant it failed to parse hides a question and reports success, and
the damage shows up in the data weeks later.
Re-exports§
pub use eval::evaluate;pub use eval::Context;pub use eval::Environment;pub use eval::Fixed;pub use eval::Value;pub use parser::parse;pub use parser::Expr;pub use portability::check_form;pub use portability::Breaks;pub use portability::Issue;pub use rules::Binding;pub use rules::Clock;pub use rules::Form;pub use rules::Rules;pub use rules::Violation;pub use rules::ViolationKind;pub use session::Outcome;pub use session::Session;pub use tree::Instance;pub use tree::NodeId;
Modules§
- eval
- Evaluating a parsed expression against an instance.
- functions
- The function library: XPath 1.0’s, plus the OpenRosa extensions.
- parser
- XPath 1.0 expression parser.
- portability
- Will this form mean the same thing on a tablet and in a browser?
- rules
- The rules a form carries, and what they say about a filled instance.
- session
- A form being filled in.
- tree
- The instance tree XPath runs over.
Functions§
- eval_
str - Parse and evaluate one expression against an instance, with
.at the root. The convenience path; a form engine keeps parsed expressions.