Skip to content

Instantly share code, notes, and snippets.

@ebruchez
Created February 20, 2013 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebruchez/4996935 to your computer and use it in GitHub Desktop.
Save ebruchez/4996935 to your computer and use it in GitHub Desktop.
<xf:action type="xpath">
for $control-name in string($local/control-name) return (
(: Set built-in type if needed :)
if ($local/builtin-type != '') then
controlOps:updateMip($form, $control-name, 'type',
concat(
if ($local/required = 'true' and not($local/builtin-type = ('listItem', 'listItems', 'dayTimeDuration', 'yearMonthDuration', 'email', 'card-number')))
then 'xs:' else 'xf:', $local/builtin-type
)
)
else (),
(: Set schema type if needed :)
(: TODO: Handle namespace and prefix for namespace :)
if ($local/schema-type != '') then
controlOps:updateMip($form, $control-name, 'type', $local/schema-type) else (),
(: "required" MIP :)
controlOps:updateMip($form, $control-name, 'required', for $v in $local/required/string() return if ($v = 'true') then 'true()' else ''),
(: All other MIPs :)
for $mip in ('constraint', 'relevant', 'readonly', 'calculate', 'default') return
controlOps:updateMip($form, $control-name, $mip, $local/*[name() = $mip])
)
</xf:action>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment