| Title: | Evaluate 'ODK'/'OpenRosa' 'XForms' Logic |
| Version: | 0.1.3 |
| Description: | Check what a questionnaire's own rules say about a submission, and which of its expressions will behave differently on a tablet than in a browser. Wraps the 'rxeval' 'Rust' crate. |
| License: | BSD_2_clause + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 8.0.0 |
| Config/rextendr/version: | 0.5.0 |
| SystemRequirements: | Cargo (Rust's package manager), rustc >= 1.65.0, xz |
| Depends: | R (≥ 4.2) |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| URL: | https://milkway.github.io/rxeval/r/, https://github.com/milkway/rxeval, https://milkway.github.io/rxeval/ |
| BugReports: | https://github.com/milkway/rxeval/issues |
| NeedsCompilation: | yes |
| Packaged: | 2026-10-28 13:42:18 UTC; leite |
| Author: | André Leite |
| Maintainer: | André Leite <leite@castlab.org> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-17 12:00:07 UTC |
Evaluate one XPath expression against a submission
Description
For working out what a rule does before writing it into a form.
Usage
eval_expression(expression, submission, today = NULL, now = NULL)
Arguments
expression |
The XPath expression, in the ODK/OpenRosa dialect. |
submission |
Path to a submission, or its XML. |
today, now |
What |
Value
A length-one character vector. An expression this engine cannot evaluate raises an error rather than returning a plausible value.
Examples
submission <- system.file("extdata", "visit-submission.xml", package = "rxeval")
eval_expression("count(/data/resident)", submission)
eval_expression("/data/residents > count(/data/resident)", submission)
Will this form mean the same thing on a tablet and in a browser?
Description
The two engines the ODK ecosystem runs on implement different languages: JavaRosa inside Collect and KoboCollect, Enketo inside web forms. Neither is a superset of the other, and the gaps do not announce themselves — an expression Collect cannot evaluate usually yields nothing rather than an error, so the form fills in, the interview finishes, and a column comes back empty.
Usage
form_portability(form)
Arguments
form |
Path to an XForm, or the XML itself. |
Details
Every rule behind this was found by putting the same expression to both engines and reading the two answers.
Value
A data frame with one row per issue. breaks says which side
stumbles: "Collect / KoboCollect", "Enketo web forms", or
"both, differently" — the last being the worst, since nothing fails
anywhere. suggestion is a rewrite that means one thing in both, or
NA when there is none to give. Zero rows means the form travels.
Examples
form <- system.file("extdata", "visit.xml", package = "rxeval")
issues <- form_portability(form)
issues[, c("path", "breaks", "suggestion")]
Evaluate one XPath expression against a submission.
Description
For working out what a rule actually does before writing it into a form.
Usage
rust_eval_expression(expression, submission, today, now)
Arguments
expression |
The XPath expression. |
submission |
Path to a submission, or its XML. |
today, now |
What |
Value
A length-one character vector. An expression the engine cannot evaluate raises an error rather than returning a plausible value.
Which expressions in a form will behave differently on a tablet than in a browser.
Description
Which expressions in a form will behave differently on a tablet than in a browser.
Usage
rust_form_portability(form)
Arguments
form |
Path to an XForm, or the XML itself. |
Value
A data frame with one row per issue: path, rule,
expression, construct, breaks, effect, suggestion, says.
Zero rows means the form travels.
What a form's own rules say about a submission.
Description
What a form's own rules say about a submission.
Usage
rust_submission_findings(form, submission, today, now)
Arguments
form |
Path to an XForm, or the XML itself. |
submission |
Path to a submission, or its XML. |
today, now |
What |
Value
A data frame: path, kind, says. Zero rows means the
submission satisfies every rule the engine could evaluate — and a
rule it could not evaluate appears as kind not-evaluated, never as
a pass.
What a form's own rules say about a submission
Description
Evaluates the questionnaire's relevant, constraint, required and
calculate against collected data, and reports what does not hold.
Usage
submission_findings(form, submission, today = NULL, now = NULL)
Arguments
form |
Path to an XForm, or the XML itself. |
submission |
Path to a submission, or its XML. |
today, now |
What |
Details
A rule the engine could not evaluate comes back as not-evaluated, never
as a pass: a rule that did not run has not been satisfied, and reporting
it as clean would be the one failure worth avoiding.
Value
A data frame of path, kind (constraint, required,
calculation, not-evaluated) and says. Zero rows means every rule
held.
Examples
form <- system.file("extdata", "visit.xml", package = "rxeval")
submission <- system.file("extdata", "visit-submission.xml", package = "rxeval")
findings <- submission_findings(form, submission)
findings[, c("path", "kind")]