api:map
Version 23.0.9145
Version 23.0.9145
api:map
Use the api:map
keyword to map attributes in one item to attributes in another item. Attributes are read from one item and written to another with the new names specified in the map string. The api:map
keyword does not clear the destination item; it adds new attributes to it. Or, if an attribute exists in the destination item, it is overwritten, and other attributes remain as they were.
Parameters
- to: The name of the item to write attributes to.
- from: The name of the item to read attributes from.
-
map: A list of attribute names that specify the attribute names in the destination item, followed by the attribute names in the source item. For example, you can map attributes with one prefix to attributes with another prefix by using the following syntax:
customer:\* = soap:\*
Any characters that are not valid attribute names are ignored and are used to demarcate the end of a name.
Control Attributes
None
Examples
Map three attributes: The map is a succession of the to
attribute name followed by the from
attribute name.
<api:set item="item1" attr="var1" value="x"/>
<api:set item="item1" attr="var2" value="y"/>
<api:set item="item2" attr="attr1" value="z"/>
<api:map to="item2" from="item1" map="attr1=var1, attr2=var2"/>
In the previous example, the var1
and var2
attributes of item1
are mapped to the attr1
and attr2
attributes of item2
. The attr1
attribute, which is set with the value z
in item2
, is overwritten with x
, the value of var1
from item1
. The attr2
attribute, which does not exist in item2
, is created and set to y
, the value of var2
in item1
.
You can map multiple attributes from items with one prefix to items with a different prefix. This is useful when changing the prefix from application prefixes (for example, soap:*
) to business domain prefixes (for example, customer:*
). The following example creates a mapping from all soap:*
attributes in the soapout
item to attributes prefixed with customer:*
in the customer
item:
<api:map from="soapout" to="customer" map="customer:* = soap:*"/>
Copy all attributes from one item to another item:
<api:map from="copyfrom" to="copyto" map="* = *"/>
See Also
- api:set: Set the attributes of an item.