// if we are dealing with multiple documents
endFragment(currentProgram, element);
}
public void start(MappingSourceNode node, Map context) {
Program currentProgram = (Program)programStack.peek();
commonStart(node, context);
String source = node.getActualResultSetName();
ResultSetInfo info= node.getResultSetInfo();
if (info.isJoinedWithParent()) {
//create a dependent while loop
JoinedWhileInstruction whileInst = new JoinedWhileInstruction(source, new Integer(info.getMappingClassNumber()),
info.getMappingClassSymbol(), node.getResultName());
currentProgram.addInstruction(whileInst);
Program childProgram = new Program();
whileInst.setBlockProgram(childProgram);
programStack.push(childProgram);
return;
}
// Add instruction to execute relational query
ExecSqlInstruction sqlInst = new ExecSqlInstruction(source, info);
currentProgram.addInstruction(sqlInst);
BlockInstruction blockInst = new BlockInstruction(source);
currentProgram.addInstruction(blockInst);
// Add instruction to read the first row in
MoveCursorInstruction moveCursor = new MoveCursorInstruction(source);
currentProgram.addInstruction(moveCursor);
// set up while instruction, add sub Program
WhileInstruction whileInst = new WhileInstruction(source);
currentProgram.addInstruction(whileInst);
Program childProgram = new Program();
whileInst.setBlockProgram(childProgram);
// when while is done close the resultset(note that the child program will
// have all the statements.
EndBlockInstruction closeInst = new EndBlockInstruction(source);