Adding an attribute to an element

Since the Actions parameter of the XmlProcessor macro is a Collection parameter, it also supports an abbreviated syntax. This is very useful for simple actions like adding an attribute to an element. For historical reasons, the existance of the checked attribute - not the value - determines whether an HTML checkbox is checked. Using this method demonstrated in this example, you can optionally add the check attribute and still use the declarative, easy to read, element notation.

Smartsite SXML CopyCode image Copy Code
<se:xmlprocessor actions="|{this.setattribute(checked,checked)}|" rem="action is applied to the outer element">
             <input name="{string.capitalize(myname)}" type="checkbox" value="true" />

<se:xmlprocessor actions="|/label/input={this.setattribute(checked,checked)}|" rem="action is applied to the selected element input">
             <label for="inp1"><input id="inp1" name="{string.capitalize(myname)}" type="checkbox" value="true" /> Checkbox</label>
Example Result CopyCode image Copy Code
<input name="Myname" type="checkbox" value="true" checked="checked" />

<label for="inp1"><input id="inp1" name="Myname" type="checkbox" value="true" checked="checked" /> Checkbox</label>