|
|
|
<value></value>
Provided by module: Tags: RXML tags
Creates a single value from its contents or some other
source. This is mainly useful to build the elements in array
or mapping contexts. E.g:
<set variable="var.arr" type="array">
<value>apple</value>
<value>orange</value>
<value>banana</value>
</set>
&var.arr; |
Array result: ({"apple", "orange", "banana"}) |
This tag takes a "type" attribute to set the type of its
content, just like e.g. <set>. That can be useful e.g. to
build arrays inside arrays:
<value type="array">
<value>1</value>
<value type="array">
<value>1.1</value>
<value>1.2</value>
</value>
<value>2</value>
</value> |
Array result: ({"1", ({"1.1", "1.2"}), "2"}) |
Note that a variable with an array value is normally spliced into
an array context. Here too an extra <value> tag is useful to
make it a nested array:
<set variable="var.x" split=",">a,b</set>
<value type="array">
<!-- Insert all the elements in var.x -->
&var.x;
<!-- Compare to the following that adds
the var.x array as a single element. -->
<value>&var.x;</value>
</value> |
Array result: ({"a", "b", ({"a", "b"})}) |
Attributes
- type="type"
-
The type of the content and the result (except if it's "array" -
then the result is "any" to avoid splicing the array into the
surrounding array, as shown above). Defaults to "any".
- index
-
Used when the surrounding type is a mapping. This specifies the
index for the value. E.g:
<value type="mapping">
<value index="1">first</value>
<value index="2">second</value>
<value index="3">third</value>
</value> |
Mapping result: (["1": "first", "2": "second", "3": "third"]) |
This attribute cannot be left out when a mapping is constructed,
and it must not be given otherwise.
- from="string"
-
Get the value from this variable. The content must be empty if
this is used.
- expr="string"
-
An expression that gets evaluated to produce the value. The
content must be empty if this is used.
|
|