Collection
Represents a collection of name-value pairs.
A collection can be specified as an xml node:
Smartsite SXML | Copy Code |
---|---|
<se:parameter name="save"> <se:collection> <se:member name="count">recordcount</se:member> <se:member name="data">datatable</se:member> </se:collection> </se:parameter> |
A collection may also be specified as a comma delimited string:
Smartsite SXML | Copy Code |
---|---|
save="count=recordcount,data=datatable" |
Depending on the module that exposes a collection parameter, the contained values may be required to be of a specific datatype:
Smartsite SXML | Copy Code |
---|---|
coordinates="x=100,y=200,z=300" |
The collection itself does not force unique keys, although the module that accepts the collection parameter might:
Smartsite SXML | Copy Code |
---|---|
coordinates="x=100,y=100,x=200,y=100,x=200,y=200,x=100,y=200" |
If the module only requires a set of values, the keys may be ommited:
Smartsite SXML | Copy Code |
---|---|
numbers="1,2,3,4,5" |
A collection member can specify a type attribute. The function of this attribute depends on the parameter that it is used for. In the SqlParams collection of the SqlQuery macro it determines the data type of the parameter. The collection will attempt to cast the given value to this type. In the save parameter the type attribute determines the scope of the buffer to be saved: global/regional.
Type can only be specified using the xml notation:
Smartsite SXML | Copy Code |
---|---|
<se:parameter name="params"> <se:collection> <se:member name="parent" type="int">3070</se:member> <se:member name="folder" type="bool">false</se:member> </se:collection> </se:parameter> |
New in 1.2
A new feature is introduced in 1.2: DataTables as inputdata for a collection.
The inputdata attribute allows you to pass a datatable to a collection and thus dynamically define the collection members. This can be very handy in situations where the list of members depends on custom logic, such as in the case of an SqlQuery macro with an Sql statement that is built up dynamically.
Smartsite SXML | Copy Code |
---|---|
<se:parameter name="params"> <se:collection inputdata="{buffer.get(myparams)}"/> </se:parameter> |
New in 1.3
When specifying collection parameters as xml attributes, using commas in values used to be a problem.
You can now specify one of the following alternative characters: ';', '|', '/', '\', '~', '#'.
To force the use of an alternative delimiter character, enclose the entire attribute value using the chosen delimiter.
Example:
Smartsite SXML | Copy Code |
---|---|
<se:embed location="1237" save="/a=string.length(this.result(), default=0, error=0)/b=this.statuscode()/" resulttype="none" /> HTTP {buffer.get(b)}: {buffer.get(a)} bytes |