getodk / xforms-spec

The XForms-derived specification used in the ODK ecosystem. If you are interested in building a tool that is compliant with the forms rendered by ODK tools, this is the place to start. ✨⚒✨
https://getodk.github.io/xforms-spec/
30 stars 26 forks source link

Document `base64-decode` and process for adding functions #301

Closed lognaturel closed 9 months ago

lognaturel commented 1 year ago

Documents base64-decode as implemented at https://github.com/getodk/javarosa/blob/203f37b702e0c5aadff45d2f7bc7010875328a5f/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java#L1260

Original proposal Opening this PR for discussion around two proposed function additions. I propose adding these in the default/XForm namespace as other custom functions have been introduced in the past. For better or worse, the ODK ecosystem doesn't use namespacing consistently and is not generally compatible with arbitrary XForms. If we do namespace new functions, we either have to expose that to end users of XLSForm or have XLSForm detect namespaced functions and inject namespacing information. The last commit in this PR describes this approach to function namespacing. `centroid` is based on http://expath.org/spec/geo#d2e981 but with ODK types. `base64Binary-to-string` is based on https://www.saxonica.com/html/documentation10/functions/saxon/base64Binary-to-string.html for its simplicity. Additional candidates: - http://expath.org/spec/binary#decode-string has more complexity than we need - https://synapse.apache.org/userguide/xpath.html#base64_decode is similar but the Saxonica function better matches our naming conventions