Escaping

Release 1.0 - ...

Escaping data in SXML works exactly like in any XML document, that is with entity encoding and CDATA sections.

Processing directives within attributes always need to be escaped:

Smartsite SXML CopyCode image Copy Code
<se:xlinks resultformat="{this.field(title)} &lt;br/&gt;" />
When using parameter notation, or when using the inner XML of macros, escaping is only needed if the XML entered is not well-formed:
Smartsite SXML CopyCode image Copy Code
<se:xlinks>
  <se:parameters>
    <se:parameter name="resultformat">
      {this.field(title)}<br />
    </se:parameter>
  </se:parameters>
</se:xlinks>
The example above breaks the XML. You can use a CDATA block to allow for a non-wellformed tag:
Smartsite SXML CopyCode image Copy Code
<se:xlinks>
  <se:parameters>
    <se:parameter name="resultformat">
      <![CDATA[
        {this.field(title)}<br/>
      ]]>
    </se:parameter>
  </se:parameters>
</se:xlinks>
When using SXML with Viper, you will also encounter situations in which expressions use the '<' and '>' characters:
Smartsite SXML CopyCode image Copy Code
<se:expression save="exp">
  <![CDATA[
    request.querystring(myint, default=0) < 5
  ]]>
</se:expression>
Without the CDATA section, you could note:
Smartsite SXML CopyCode image Copy Code
<se:expression save="exp">
  request.querystring(myint, default=0) &lt; 5
</se:expression>
To eliminate the need for escaping while also making the code more readable, the Viper expression parser supports the special directives LT, LTE, GT, GTE:
Smartsite SXML CopyCode image Copy Code
<se:expression save="exp">
  request.querystring(myint, default=0) LT 5
</se:expression>