Is your input document going to be flat? If it is not then you will have to code for all things that can be in a document. Below is some rudimentary code for you to begin with, you can modify this code to manipulate IData.
Try adding the IData to the same code below and that should handle everything that can come in a IData document. I am leaving that to you to figure it out.
IDataCursor pipelineCursor = pipeline.getCursor();
IData inputDoc = IDataUtil.getIData( pipelineCursor, "inputDoc" );
if ( inputDoc != null)
{
//Create a dynamic output array to store the key\value pairs from the document.
ArrayList<IData> outputDocarr = new ArrayList<IData>();
ArrayList<String> temp=new ArrayList<String>();
IDataCursor idc=inputDoc.getCursor();
IData output=null;
IDataCursor idcOut=null;
while(idc.next()){
output= IDataFactory.create();
idcOut= output.getCursor();
// Add to the output doc array only if the cursor has a string or object key\value pair.
if ((idc.getValue() instanceof String) ||((idc.getValue() instanceof Object))){
IDataUtil.put(idcOut, "key", idc.getKey());
IDataUtil.put(idcOut, "value", idc.getValue());
idcOut.destroy();
outputDocarr.add(output);
}
else if(idc.getValue() instanceof IData){
idc.next();
}
//value is empty
else if(idc.getValue()==null){
temp.add(idc.getKey());
IDataUtil.put(idcOut, "key", idc.getKey());
IDataUtil.put(idcOut, "value", null);
outputDocarr.add(output);
}
}
IDataUtil.put( pipelineCursor, "outputDocList", outputDocarr.toArray(new IData[outputDocarr.size()]));
IDataUtil.put(pipelineCursor, "test", temp.toArray(new String[temp.size()]));
}
pipelineCursor.destroy();
#webMethods#Flow-and-Java-services#Integration-Server-and-ESB