The string-ifempty() function
Smartsite 7.2 - ...
The string-ifempty() extension function returns either the first argument or the second argument when the first argument resolves to null or an empty string.
XML | Copy Code |
---|---|
string exf:string-ifempty(arg1, arg2) |
Parameters:
- arg1: A node reference or string literal.
- arg2: A node reference or string literal.
Example
XML | Copy Code |
---|---|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0"> <head> <title>Example</title> <xf:model> <xf:instance> <data xmlns=""> <postcode>2628 XG</postcode> <text1>Tekst 1</text1> <empty /> </data> </xf:instance> </xf:model> </head> <body> <xf:group ref="/data" appearance="full"> <xf:label /> <xf:output value="exf:string-ifempty('', text1)" /> <xf:output value="exf:string-ifempty(empty, text1)" /> <xf:output value="exf:string-ifempty(empty, 'alternatieve tekst')" /> <xf:output value="exf:string-ifempty(postcode, '(leeg)')" /> </xf:group> </body> </html> |
The result will be:
Tekst 1
Tekst 1
alternatieve tekst
2628 XG
Namespace
This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).