1.1 --- a/XSLForms/Output.py Mon Nov 28 01:28:31 2005 +0000
1.2 +++ b/XSLForms/Output.py Mon Nov 28 16:44:46 2005 +0000
1.3 @@ -316,6 +316,22 @@
1.4
1.5 # Utility functions.
1.6
1.7 +def choice(context, value, true_string, false_string=None):
1.8 +
1.9 + """
1.10 + Exposed as {template:choice(value, true_string, false_string)}.
1.11 +
1.12 + Using the given boolean 'value', which may itself be an expression evaluated
1.13 + by the XSLT processor, return the 'true_string' if 'value' is true or the
1.14 + 'false_string' if 'value' is false. If 'false_string' is omitted and if
1.15 + 'value' evaluates to a false value, an empty string is returned.
1.16 + """
1.17 +
1.18 + if value:
1.19 + return true_string
1.20 + else:
1.21 + return false_string or ""
1.22 +
1.23 def url_encode(context, nodes, charset="utf-8"):
1.24
1.25 """
1.26 @@ -410,6 +426,7 @@
1.27
1.28 # Utility functions.
1.29
1.30 +libxsltmod.xsltRegisterExtModuleFunction("choice", "http://www.boddie.org.uk/ns/xmltools/template", choice)
1.31 libxsltmod.xsltRegisterExtModuleFunction("url-encode", "http://www.boddie.org.uk/ns/xmltools/template", url_encode)
1.32 libxsltmod.xsltRegisterExtModuleFunction("element-path", "http://www.boddie.org.uk/ns/xmltools/template", element_path)
1.33