WebSphere Message Brokers
File: ak20820_
Writer: Terry Cowling

Task topic

This build: July 31, 2007 21:32:59

Mapping between a list and a repeating element

Consider the form of the following XML input message:
   <MRM>
     <inner>abcde fghij 12345</inner>
   </MRM> 
where the element inner is of type xsd:list, and therefore has three associated string values, rather than a single value.
To copy the three values into an output message, where each value is associated with an instance of repeating elements as shown here:
   <MRM>
     <str1>abcde</str1>
     <str1>fghij</str1>
     <str1>12345</str1>
   </MRM> 
you might expect that the following ESQL syntax works:
   DECLARE D INTEGER;
   SET D = CARDINALITY(InputBody.str1.*[]);
   DECLARE M INTEGER 1;
   WHILE M <= D DO
      SET OutputRoot.MRM.str1[M] = InputBody.inner.*[M];
      SET M = M + 1;
   END WHILE;
However, the statement:
	SET OutputRoot.MRM.str1[M] = InputBody.inner.*[M];
requests a tree copy from source to target. Because the target element does not yet exist, the statement creates it, and its value and type are set from the source.
Therefore, to create the output message with the required format, given an input element which is of type xsd:list, use the FIELDVALUE function to explicitly retrieve only the value of the source element:
	SET OutputRoot.MRM.str1[M] = FIELDVALUE(InputBody.inner.*[M]);
Related tasks
Developing ESQL
Accessing elements in the message body
Related reference
SET statement
FIELDVALUE function
Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2007Copyright IBM Corporation 1999, 2007. All Rights Reserved.
This build: July 31, 2007 21:32:59

ak20820_ This topic's URL is: