| Title: | Evaluate 'ODK'/'OpenRosa' 'XForms' Logic |
|---|---|
| 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. |
| Authors: | André Leite [aut, cre] (ORCID: <https://orcid.org/0000-0002-4718-9766>), Raydonal Ospina [aut] (ORCID: <https://orcid.org/0000-0002-9884-9090>), Cristiano Ferraz [aut] (ORCID: <https://orcid.org/0000-0002-6838-6734>), The authors of the vendored Rust crates [cph] (see inst/AUTHORS for details) |
| Maintainer: | André Leite <[email protected]> |
| License: | BSD_2_clause + file LICENSE |
| Version: | 0.1.3 |
| Built: | 2026-11-17 15:37:02 UTC |
| Source: | https://github.com/cran/rxeval |
For working out what a rule does before writing it into a form.
eval_expression(expression, submission, today = NULL, now = NULL)eval_expression(expression, submission, today = NULL, now = NULL)
expression |
The XPath expression, in the ODK/OpenRosa dialect. |
submission |
Path to a submission, or its XML. |
today, now
|
What |
A length-one character vector. An expression this engine cannot evaluate raises an error rather than returning a plausible value.
submission <- system.file("extdata", "visit-submission.xml", package = "rxeval") eval_expression("count(/data/resident)", submission) eval_expression("/data/residents > count(/data/resident)", submission)submission <- system.file("extdata", "visit-submission.xml", package = "rxeval") eval_expression("count(/data/resident)", submission) eval_expression("/data/residents > count(/data/resident)", submission)
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.
form_portability(form)form_portability(form)
form |
Path to an XForm, or the XML itself. |
Every rule behind this was found by putting the same expression to both engines and reading the two answers.
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.
form <- system.file("extdata", "visit.xml", package = "rxeval") issues <- form_portability(form) issues[, c("path", "breaks", "suggestion")]form <- system.file("extdata", "visit.xml", package = "rxeval") issues <- form_portability(form) issues[, c("path", "breaks", "suggestion")]
For working out what a rule actually does before writing it into a form.
rust_eval_expression(expression, submission, today, now)rust_eval_expression(expression, submission, today, now)
expression |
The XPath expression. |
submission |
Path to a submission, or its XML. |
today, now
|
What |
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.
rust_form_portability(form)rust_form_portability(form)
form |
Path to an XForm, or the XML itself. |
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.
rust_submission_findings(form, submission, today, now)rust_submission_findings(form, submission, today, now)
form |
Path to an XForm, or the XML itself. |
submission |
Path to a submission, or its XML. |
today, now
|
What |
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.
Evaluates the questionnaire's relevant, constraint, required and
calculate against collected data, and reports what does not hold.
submission_findings(form, submission, today = NULL, now = NULL)submission_findings(form, submission, today = NULL, now = NULL)
form |
Path to an XForm, or the XML itself. |
submission |
Path to a submission, or its XML. |
today, now
|
What |
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.
A data frame of path, kind (constraint, required,
calculation, not-evaluated) and says. Zero rows means every rule
held.
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")]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")]