* of {@link ContextStackFrame}
* @throws java.util.NoSuchElementException
* iteration has no more elements.
*/
public Object next() {
XPathContext context = next;
if (context == null) {
return null;
}
int construct = context.getOriginatingConstructType();
Object origin = context.getOrigin();
if (first) {
// these constructs are only considered if they appear at the top of the stack
if (construct == Location.FILTER_EXPRESSION ||
construct == Location.PATH_EXPRESSION ||
construct == Location.SORT_KEY ||
construct == Location.GROUPING_KEY) {
} else {
}
}
if (construct == Location.CONTROLLER) {
next = context.getCaller();
return new ContextStackFrame.CallingApplication();
} else if (construct == Location.BUILT_IN_TEMPLATE) {
next = context.getCaller();
return new ContextStackFrame.BuiltInTemplateRule();
}
// InstructionInfo info;
// if (origin instanceof Instruction) {
// info = ((Instruction)origin);
// } else {
// next = context.getCaller();
// return next();
// }
//System.err.println("Construct: " + construct);
if (construct == Location.FUNCTION_CALL) {
ContextStackFrame.FunctionCall sf = new ContextStackFrame.FunctionCall();
UserFunctionCall ufc = (UserFunctionCall)origin;
sf.setSystemId(ufc.getSystemId());
sf.setLineNumber(ufc.getLineNumber());
sf.setContainer(ufc.getContainer());
sf.setFunctionName(ufc.getFunctionName());
sf.setContextItem(context.getContextItem());
next = context.getCaller();
return sf;
} else if (construct == StandardNames.XSL_APPLY_TEMPLATES) {
ContextStackFrame.ApplyTemplates sf = new ContextStackFrame.ApplyTemplates();
ApplyTemplates loc = (ApplyTemplates)origin;
sf.setSystemId(loc.getSystemId());
sf.setLineNumber(loc.getLineNumber());
sf.setContainer(loc.getContainer());
sf.setContextItem(context.getContextItem());
next = context.getCaller();
return sf;
} else if (construct == StandardNames.XSL_CALL_TEMPLATE) {
ContextStackFrame.CallTemplate sf = new ContextStackFrame.CallTemplate();
CallTemplate loc = (CallTemplate)origin;
sf.setSystemId(loc.getSystemId());
sf.setLineNumber(loc.getLineNumber());
sf.setContainer(loc.getContainer());
sf.setTemplateName(loc.getObjectName());
sf.setContextItem(context.getContextItem());
next = context.getCaller();
return sf;
} else if (construct == StandardNames.XSL_VARIABLE) {
ContextStackFrame.VariableEvaluation sf = new ContextStackFrame.VariableEvaluation();
GeneralVariable var = ((GeneralVariable)origin);
sf.setSystemId(var.getSystemId());
sf.setLineNumber(var.getLineNumber());
sf.setContainer(var.getContainer());
sf.setContextItem(context.getContextItem());
sf.setVariableName(var.getVariableQName());
next = context.getCaller();
return sf;
} else if (construct == StandardNames.XSL_FOR_EACH) {
ContextStackFrame.ForEach sf = new ContextStackFrame.ForEach();
ForEach var = ((ForEach)origin);
sf.setSystemId(var.getSystemId());
sf.setLineNumber(var.getLineNumber());
sf.setContainer(var.getContainer());
sf.setContextItem(context.getContextItem());
next = context.getCaller();
return sf;
// } else if (construct == Location.FILTER_EXPRESSION) {
// out.println(" In predicate of filter expression");
// } else if (construct == Location.PATH_EXPRESSION) {
// out.println(" In step of path expression");
// } else if (construct == Location.SORT_KEY) {
// out.println(" In evaluation of sort key");
// } else if (construct == Location.GROUPING_KEY) {
// out.println(" In evaluation of grouping key");
} else {
//other context changes are not considered significant enough to report
//out.println(" In unidentified location " + construct);
next = context.getCaller();
return next();
}
}