Mapping multiple <any> elements
In this map the business objects have more than one
<any> element
in the schema definition.
About this task
<any> elements you
would need to write custom code. Automated transformations involving
more than one <any> are not supported
because <any> elements do not have a name associated
with them and it is not possible to determine within the current mapping
framework which <any> element the data belongs
to. When setting more than one <any> element,
you must do it in relation to the occurrence of the <any> to
some other identifying element. For retrieving the <any> element
data, the data object sequence will have to be used to determine which <any> tag
the data originated from in relation to some other identifying element
or attribute.
Considering the following map:
You would use the following
custom code for moving multiple 
<any> elements
from source to target in relation to the occurrence of the <any>:
// Variable AnyElemAny is represented as AnyElemAny_1
ServiceManager serviceManager = new ServiceManager();
Bofactory bofactory = (BOFactory)serviceManager.locateService("com/ibm/websphere/bo/BOFactory");
OXSDHelper xsdHelper = (BOXSDHelper)serviceManager.locateService("com/ibm/websphere/bo" );
// retrieve the data from the source - Source BO has already been set with the properties
// that are retrieved below
Property marker1Prop = AnyElemAny.getType().getProperty("marker1");
Property firstAnyProp = (Property)
AnyElemAny.getInstanceProperties().get(1);
Property secondAnyProp = (Property)
nyElemAny.getInstanceProperties().get(2);
// Another way of getting the data in addition to the above is as follows :
firstAnyProp = AnyElemAny.getInstanceProperty("globalElement1");
Object firstAnyData = AnyElemAny.get(firstAnyProp);
secondAnyProp = AnyElemAny.getInstanceProperty("globalElement2");
Object secondAnyData = AnyElemAny.get(secondAnyProp);
Object markerData = AnyElemAny.get(marker1Prop);
// Set the data on the target BO,
// retrieve the global property fields on the target and set using the data from the source
Property prop1 = xsdHelper.getGlobalProperty("http://GlobalElems", "globalElement1", true);
Property prop2 = xsdHelper.getGlobalProperty("http://GlobalElems", "globalElement2", true);
AnyElemAny_1.set(prop1,firstAnyData);
AnyElemAny_1.set("marker1",markerData);
AnyElemAny_1.set(prop2,secondAnyData);
This topic only applies to BAW, and is located in the BAW repository. Last updated on 2025-03-13 12:15