Serializing Name Value Pairs in Tibco BW
I used a combination of concat sequence and an internal for loop to take the name value pairs from the repeating element and put them with a '::' delimiter and then delimited the pairs by a ';'.
Input data
<?xml version = "1.0" encoding = "UTF-8"?>
<root>
<MyPairs>
<Name>A</Name>
<Value>1</Value>
</MyPairs>
<MyPairs>
<Name>B</Name>
<Value>2</Value>
</MyPairs>
<MyPairs>
<Name>C</Name>
<Value>3</Value>
</MyPairs>
</root> |
Output Data
<?xml version = "1.0" encoding = "UTF-8"?>
<root>
<MyString>A::1;B::2;C::3;</MyString>
</root> |
The mapper formula
tib:concat-sequence(
for $var in $Start/root/MyPairs return
concat(
(if (string-length($var/Name)!=0) then $var/Name else 'NULL' ) ,'::',
(if (string-length($var/Value)!=0) then $var/Value else 'NULL' ) ,';'
)
) |