viv:url-add-non-void-params

adds name/value pairs to a URL only when value is non-void

Synopsis

string
	viv:url-add-non-void-params
	(url, name, value, [...]);
string    url;
string    name;
string    value;
[...]    [...];

Description

Append name/value pairs of CGI parameters to a URL ONLY when the value is non void, adding '?' and the '&' separator when necessary, and escaping the parameters properly. Note that any number of name/value pair can be added, the number of arguments just needs to be odd.

Arguments

  • url: the parameters to which the CGI parameters will be added.
  • name: the name of a CGI parameter
  • value: the value of a CGI parameter, if this is NULL or a void string, the parameter is NOT added.

Returns

the URL with the parameters appended

Example

    <xsl:value-of select="viv:url-add-non-void-params(
    'http://z.com/ok?a=b',
    'c', 'd',
    'e', '',
    'f', 'g h')" />

Calling the previous function will return the following:

    http://z.com/ok?a=b&c=d&f=g_h