Formatting helpers

Encoding and decoding XML

The Code Editor provides a very usefull feature for XML encoding and decoding a selected text. XML decode replaces the five predefined XML entity references with their actual value as listed below.

Entity Symbol
&lt; <
&gt; >
&amp; &
&apos; '
&quot; "

Encoding is the reverse process.

xml encode


Two keyboard short-cuts exist for formatting a document and a selection. The formatting provides automatic indentation when applied. CTRL-K-F formats a selection, CTRL-K-D formats an entire document.

Parameter conversion

The SXML code editor provides a syntax conversion tool for SXML parameters. In part II of the series about the SXML code editor a detailed description of this tool.

SXML parameter syntax

The SXML syntax allows for specifying a module parameter in either the attribute or parameter syntax. The following code snippet illustrates their use in the se:text module.

Smartsite SXML CopyCode image Copy Code
<!-- Attribute syntax -->
<se:text value="Hello world" />
Smartsite SXML CopyCode image Copy Code
<!-- Parameter syntax -->
  <se:parameter name="value">Hello world</se:parameter>

Rewriting a module parameter by hand from one syntax to another is a tedious job. Thankfully the code editor provides the tools for automatic parameter syntax conversion.

Syntax conversion

Right-mouse click on a module, module attribute or module parameter displays the contextmenu of the editor. The Parameters sub menu contains the syntax conversion helpers.

parameters menu

Selection To attribute syntax *) To parameter syntax **)
Module element Converts all module parameters to attributes Converts module parameters to parameter syntax
Module attribute N/A Converts selected attribute to parameter syntax
Parameter element (<se:parameter>) Converts selected parameter to attribute syntax N/A

*) Conversion from parameter to attribute syntax includes XML encoding of the content. If the content of a parameter contains nested modules, the conversion will fail.

**) A number of module parameters cannot be written in the parameter syntax, they must appear as attribute (whitespace parameter for instance). The conversion tool takes this into account and will not convert these attribute to the parameter syntax.

Example of se:text converted from parameter to attribute syntax.

Smartsite SXML CopyCode image Copy Code
<!-- Original parameter syntax -->
<se:text whitespace="remove">
  <se:parameter name="error">oops</se:parameter>
  <se:parameter name="value">
   <b>Hello World</b>
Smartsite SXML CopyCode image Copy Code
<!-- Converted attribute syntax -->
<se:text error="oops" value="Hello World" whitespace="remove" />


There are a number of situations where the conversion cannot be performed. For example, when the module XML content is not well-formed, the tool is unable to perform the conversion. Whenever the conversion tool encounters a problem, it will display a message box containing details of the issue at hand.

The option Parameter attributes on new line in the Parameters context menu provides the option to specify how to output module attribute. When the option is checked, each module attribute will appear on a new line.