The string-enclose() function

Smartsite 7.2 - ...

The string-enclose() extension function returns a new string, in which the specified string (first argument) is prefixed (second argument) and optionally suffixed (third argument)with the specified string(s). When the specified string (first argument) is null or empty, an empty string is returned.

XML CopyCode image Copy Code
string exf:string-enclose(arg1, string prefix, string suffix)

Parameters:

  • arg1: a node reference or string literal.
  • string: the prefix.
  • string (optional): the suffix. 

Example

XML CopyCode image 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="">     
    </data>
   </xf:instance>
  </xf:model>
 </head>
 <body>
  <xf:group ref="/data" appearance="full">
   <xf:label />
   <xf:output value="exf:string-enclose('literal','prefix-')" />
   <xf:output value="exf:string-enclose('literal','prefix-','-suffix')" />
   <xf:output value="exf:string-enclose('literal','','-suffix')" />  </xf:group>
 </body>
</html>

The result will be:

prefix-literal
prefix-literal-suffix
literal-suffix


Namespace

This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).