Mapping xsd:any[]
A business object which has an xsd:any[] will have the
maxOccurs
= "unbounded" in the type declaration for the <any> element.
This would imply that the <any> element can hold
multiple values within the same property that was used to define it.
About this task

The map above shows a
custom code snippet that iterates over each of the values set on the
<any> element
and copies specific values to the target <any> element
which is also an array. There is no special condition defined here
for the copying, but this can be easily done:// Variable AnyElemAny is represented as AnyElemAny_1
ServiceManager serviceManager = new ServiceManager();
Bofactory bofactory = (BOFactory)serviceManager.locateService("com/ibm/websphere/bo/BOFactory");
BOXSDHelper xsdHelper = (BOXSDHelper)serviceManager.locateService("com/ibm/websphere/bo" );
// Retrieve the values in the xsd:any[] on the source and populate the target
int instancePropertyCount = AnyMany.getInstanceProperties().size();
int definedPropertyCount = AnyMany.getType().getProperties().size();
// If equal, then the Source BO does not have data corresponding to xsd:any
if (instancePropertyCount == definedPropertyCount)
System.out.println("no open properties found");
// Iterate through each of the properties and get the value
// set the target
Property property = null;
// target Sequence
Sequence seq = AnyMany_1.getSequence();
Property targetAnyProperty = xsdHelper.getGlobalProperty("http://GlobalElems", "globalElement1", true);
for (int i = definedPropertyCount; i < instancePropertyCount; i++)
{
property = (Property) AnyMany.getInstanceProperties().get(i);
if (xsdHelper.isElement(property)) {
Object data = AnyMany.get(property);
// set this data on the target
seq.add(targetAnyProperty,data);
}
}
This topic only applies to BAW, and is located in the BAW repository. Last updated on 2025-03-13 12:15