Open dmenne opened 3 years ago
Thanks, I'll have a look! We definitely should add some tests for translated hints. Feel free to share your tests or test ideas!
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]]
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.