Whitespace Handling

Release 1.0 - ...

When developing a page in SXML, you as a developer might want to put several SXML instructions on multiple lines for readability. This may lead to excessive whitespace in the output of your page. SXML gives you control over the whitespace in the output using the whitespace and trim parameters.

You can control whitespace in the output by setting the whitespace parameter on a macro or viper. The whitespace parameter on a macro applies to the data inside the macro, the whitespace parameter on a viper applies to the whitespace surrounding the viper. You can set one of the following values to the whitespace parameter of a macro or viper.

  • preserve
    Preserve is the default value and leaves the whitespace as is.
  • remove
    Remove removes all the whitespace. This option is in most cases of little use since words are glued together in this mode.
  • normalize
    Normalize replaces every sequence of one or more whitespace characters (with newline in it)by a single space.
  • simpleformat
    Simpleformat replaces every sequence of one or more whitespace characters without a newline by a single space and replaces every sequence of one or more whitespace characters with a newline in it by a newline character.

Another way to control whitespace is by setting the trim parameter on a macro. Trim does not exist on vipers. Trim is applied to data inside a macro. It is applied to all the parameters in xml notation when defined on the macro. Trim removes whitespace at the beginning and/or at the end of each parameter value. Valid values for trim are:

  • none
    None is the default value and leaves the whitespace as is.
  • left
    Left removes all the whitespace characters on the left side of the parameter value.
  • right
    Right removes all the whitespace characters on the right side of the parameter value.
  • both
    Both removes all the whitespace characters on the left and right side of the parameter value.