Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for translated hints #107

Open
dmenne opened this issue Nov 19, 2020 · 2 comments
Open

Tests for translated hints #107

dmenne opened this issue Nov 19, 2020 · 2 comments
Assignees
Labels
feature a feature request or enhancement

Comments

@dmenne
Copy link
Contributor

dmenne commented Nov 19, 2020

I am using your xml- files to test my version of form_schema_ext that uses xslt. I noted that there are no tests for translated hints - or did I miss these. I made some quick-and-dirty hand-crafted ones, but it would be nice if we could share official test versions.

@dmenne dmenne added the feature a feature request or enhancement label Nov 19, 2020
@florianm
Copy link
Collaborator

Thanks, I'll have a look! We definitely should add some tests for translated hints. Feel free to share your tests or test ideas!

@dmenne
Copy link
Contributor Author

dmenne commented Nov 20, 2020

XML-to-dataframe unwrapping works nicely with XSLT, and the XSLT files look deceivingly simple. However, I better don't tell you how long I needed to get the syntax straight, since only XSLT 1.0 is allowed with R, too many restrictions apply.

library(xslt)

xml_files = dir(system.file("extdata/", package = "ruODK"),
                pattern = "I8.*.xml",
                full.names = TRUE)
form_style = read_xml("odkapi_form.xsl")
languages_style = read_xml("odkapi_languages.xsl")
choices_style = read_xml("odkapi_choices.xsl")

forms = sapply(xml_files, function(xml_files) {
  doc = read_xml(xml_file)
  languages_xslt = as.character(xml_xslt(doc, languages_style), params = list())
  languages = read.delim(textConnection(as.character(languages_xslt)), header = TRUE)$lang
  lapply(languages, function(language) {
    xx = xml_xslt(doc, form_style, params = list(lang = language))
    read.delim(textConnection(as.character(xx)), header = TRUE)
  })
})

# example (French)
forms[[9]]

xslt.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants