Getting Started

Release 1.0 - ...

Smartsite iXperion has a powerful way to format the result of macros. The formatting is independant from the datasource the information is retrieved from. Once passing the Smartsite iXperion meta-layer, information is uniform; a directory listing is formatted in the same way as data stored in a database table.

The formatting consists of several parameters of which two apply to every macro. The other parameters apply to so called ResultSet macros. ResultSet macros, e.g. XLinks, Dir and SqlQuery are macros that return a table of data, containing one or more rows and one or more columns containing data.

The macro parameters that apply to every macro:

The macro parameters that apply to the ResultSet macros:

During execution and when execution has finished, results can be displayed using local viper methods. The ResultFormat parameter is used to format the complete result of the macro. To display the result, a local viper method this.result() is used.

Formatting the result

Almost every macro returns a result. This result can be formatted using the ResultFormat parameter. To embed the result within a line of text, a local viper method this.result() can be used:

Smartsite SXML CopyCode image Copy Code
<se:itemdata field="title" resultformat="{html.tag(h1,this.result())}" />
 
<se:if expression="1==1">
 <se:parameters>
  <se:parameter name="xml">
   <se:then>one is equal to one</se:then>
   <se:else>one is not equal to one</se:else>
  </se:parameter>
  <se:parameter name="resultformat">
   <p>Did you know that: {this.result()}</p>
  </se:parameter>
 </se:parameters>
</se:if>

If a macro returns no result, the value of the Default parameter is displayed:

Smartsite SXML CopyCode image Copy Code
<se:xlinks parent="27424">
 <se:parameters>
  <se:parameter name="rowformat">{this.field(title)}</se:parameter>
  <se:parameter name="rowdelimiter"><br /></se:parameter>
  <se:parameter name="resultformat">
   <h3>Children of folder{url.getitemnumber(this.getparameter(parent))}</h3>
   {this.result()}
  </se:parameter>
  <se:parameter name="default">
   folder {url.getitemnumber(this.getparameter(parent))} has no front-end availlable children
  </se:parameter>
 </se:parameters>
</se:xlinks>

Datatables

The result of a macro is often not a single string. An XLinks macro or an SQLQuery macro return tables of information which should be formatted. This resulttype of a macro is strongly typed and called a datatable. Some vipers return datatables as well. The formatting is based on these datatable type. A datatable is collection of rows and columns.

Simple formatting

Simple formatting is focussed on formatting the rows in the datatable. The RowFormat parameter is used to specify the format of each row. Within the RowFormat parameter, the local viper method this.field() can be used to display the value of an individual field of that row. The this.field() viper-method uses the column-name or the column number:

Smartsite SXML CopyCode image Copy Code
<se:xmldatatable>
    <se:parameters>
        <se:parameter name="xml">
            <se:row><se:col name="Nr">12</se:col><se:col name="Name">John</se:col></se:row>
            <se:row><se:col>37</se:col><se:col>Karin</se:col></se:row>
            <se:row><se:col>43</se:col><se:col>Peter</se:col></se:row>
        </se:parameter>
        <se:parameter name="rowformat">{this.field(nr)} - {this.field(2)}</se:parameter>
        <se:parameter name="rowdelimiter"><br /></se:parameter>
        <se:parameter name="resultformat">
            <h3>All Users</h3>
            <p>
                {this.result()}
            </p>
        </se:parameter>
    </se:parameters>
</se:xmldatatable>

The SkipRows parameter and the MaxRows parameter can be used filtering the results.

Advanced formatting

It becomes more interesting when we use advanced formatting. When using this kind of formatting all formatting, except the resultformat, is moved into the format parameter. Within this parameter, an XML structure defines the output. This XML structure looks very similar to the other parameters, however they can be directly declared by name within the se namespace. The result of above can be written like this as well:

Smartsite SXML CopyCode image Copy Code
<se:xmldatatable>
    <se:parameters>
        <se:parameter name="xml">
            <se:row><se:col name="Nr">12</se:col><se:col name="Name">John</se:col></se:row>
            <se:row><se:col>37</se:col><se:col>Karin</se:col></se:row>
            <se:row><se:col>43</se:col><se:col>Peter</se:col></se:row>
        </se:parameter>
        <se:parameter name="format">
            <se:rowformat>{this.field(nr)} - {this.field(2)}</se:rowformat>
            <se:rowdelimiter><br /></se:rowdelimiter>
        </se:parameter>
        <se:parameter name="resultformat">
            <h3>All Users</h3>
            <p>
                {this.result()}
            </p>
        </se:parameter>
    </se:parameters>
</se:xmldatatable>

This notation opens new ways to format the result. For example, the rowformat parameter can be duplicated. To distinguish the different row format parameters from eachother, one of them marked with an expression. All rows mathing the expression are using the particular rowformat, the other rows use the fallback, i.e. the rowformat parameter with no expression attribute. If no fallback is defined, these rows are excluded from the output:

Smartsite SXML CopyCode image Copy Code
<se:xmldatatable>
    <se:parameters>
        <se:parameter name="xml">
            <se:row><se:col name="Nr" datatype="integer">12</se:col><se:col name="Name">John</se:col></se:row>
            <se:row><se:col>37</se:col><se:col>Karin</se:col></se:row>
            <se:row><se:col>43</se:col><se:col>Peter</se:col></se:row>
        </se:parameter>
        <se:parameter name="format">
            <se:rowformat expression="this.field(Nr) % 2 == 1"><em>{this.field(nr)} - {this.field(2)}</em></se:rowformat>
            <se:rowformat>{this.field(nr)} - {this.field(2)}</se:rowformat>
            <se:rowdelimiter><br />{char.crlf()}</se:rowdelimiter>
        </se:parameter>
        <se:parameter name="resultformat">
            <h3>All Users</h3>
            <p>
                {this.result()}
            </p>
        </se:parameter>
    </se:parameters>
</se:xmldatatable>