}
out.println("{");
out.pushDepth();
AbstractPattern select = parseSelect(_select);
boolean hasExprEnv = ! allowJavaSelect(select);
int id = _gen.generateId();
String sel = "_xsl_sel" + id;
String oldCxt = "_xsl_cxt" + id;
String oldCur = "_xsl_cur" + id;
String oldSel = "_xsl_old_sel" + id;
String oldEnv = "_xsl_env" + id;
String oldSize = "_xsl_old_size" + id;
out.println("com.caucho.xpath.pattern.AbstractPattern " + sel + ";");
out.print(sel + " = _select_patterns[");
out.print(_gen.addSelect(select));
out.println("];");
out.println("Node " + oldCxt + " = env.getContextNode();");
out.println("Node " + oldCur + " = env.getCurrentNode();");
if (! hasExprEnv) {
out.println("AbstractPattern " + oldSel + " = env.setSelect(node, " + sel + ");");
out.println("int " + oldSize + " = env.setContextSize(0);");
}
// String pos = "_xsl_pos" + unique++;
String iter = "_xsl_iter" + _gen.generateId();
int oldSelectDepth = _gen.getSelectDepth();
// println("int " + pos + " = 0;");
boolean hasEnv = false;
if (allowJavaSelect(select)) {
out.println("ExprEnvironment " + oldEnv + " = env.setExprEnv(null);");
String ptr = printSelectBegin(out, select, true, null);
_gen.pushLoop();
out.println("Node " + _gen.getElement() + " = node;");
out.println("node = " + ptr + ";");
}
else {
out.print("NodeIterator " + iter + " = " + sel);
out.println(".select(node, " + getEnv() + ");");
out.println("ExprEnvironment " + oldEnv + " = env.setExprEnv(" + iter + ");");
out.println("while (" + iter + ".hasNext()) {");
out.pushDepth();
_gen.setSelectDepth(_gen.getSelectDepth() + 1);
_gen.pushLoop();
out.println("Node " + _gen.getElement() + " = node;");
out.println("node = " + iter + ".nextNode();");
}
out.println("env.setCurrentNode(node);");
// println(pos + "++;");
// String oldPos = currentPos;
// currentPos = pos;
AbstractPattern oldNodeListContext = _gen.getNodeListContext();
_gen.setNodeListContext(parseMatch(_select));
generateChildren(out);
_gen.setNodeListContext(oldNodeListContext);