rsb:set
The rsb:set keyword sets a value in an attribute. If an attribute is set in an item that does not exist, it is automatically created. The rsb:set keyword can also be used to add prefix-to-namespace mapping for an item.
There are two ways to set a value using rsb:set. You can set the value parameter, or, for large values that are multi-line and complex, you can set the value using the scope of the keyword itself.
Parameters:
- item: The item parameter is used to specify the item in which the attribute is set. Specifying an item is not required. If an item is not specified, the default item is used.
- attr: The attr parameter is used to specify the name of the attribute. You may also specify the item by prefixing it to the attribute name and separating it with a "." (e.g.: item.prefix:attr). Note that a complete attr name takes the form file:name, where "file" is the prefix followed by ":", and then followed by "name". Although it is possible to create and work with attributes without prefixes, these attributes should not be pushed to the output. The RSSBus Engine will automatically assign the prefix "x" to attributes without a prefix when they are pushed out as RSS items, in order to comply with the RSS v2.0 specification.
- ns: The ns parameter takes a value in the format "xmlns:myprefix=http://www.example.org". It binds the prefix "myprefix" to the namespace "http://www.example.org" in the item specified. If the item is later pushed as RSS output, the namespace mapping will be used to bind the attributes with the prefix "myitem".
- value: The value to be assigned to the attribute. If value is not provided, the entire body of the rsb:set keyword is used as the value. This is convenient for setting long or multi-line values.
- copyfrom: The "copyfrom" parameter can be used to copy attributes from the item specified in "copyfrom" to the item specified in "item".
Control Attributes:
- This keyword does not have any control attributes.
Examples:
In the following example, the scope of the keyword is used to set a value to the message attribute of the item input:
In this example, the prefix "customer" is mapped to the namespace "http://www.mycompany.com/customer" for the item named "output":<rsb:set item="input" attr="message"> Dear [name], You have won a cruise trip to Hawaii. Please confirm your acceptance by [date]. Thanks, [sales] </rsb:set>
<rsb:set item="output" ns="xmlns:customer=http://www.mycompany.com/customer"/>
See Also:
- rsb:unset: To learn how to remove an attribute from an item.