if (curr == null) {
break;
}
if (curr instanceof XSLWhen) {
conditions[w] = ((XSLWhen)curr).getCondition();
Expression b = ((XSLWhen)curr).compileSequenceConstructor(
exec, decl, curr.iterateAxis(Axis.CHILD));
if (b == null) {
b = Literal.makeEmptySequence();
}
try {
b = makeExpressionVisitor().simplify(b);
if (LogConfiguration.loggingIsEnabled() && LogController.traceIsEnabled()) {
String test = XSLIf.getTestAttribute((XSLWhen)curr);
conditionTests[w] = test;
}
actions[w] = b;
} catch (XPathException e) {
compileError(e);
}
// Optimize for constant conditions (true or false)
if (conditions[w] instanceof Literal && ((Literal)conditions[w]).getValue() instanceof BooleanValue) {
if (((BooleanValue)((Literal)conditions[w]).getValue()).getBooleanValue()) {
// constant true: truncate the tests here
entries = w+1;
break;
} else {
// constant false: omit this test
w--;
entries--;
}
}
w++;
} else if (curr instanceof XSLOtherwise) {
conditions[w] = Literal.makeLiteral(BooleanValue.TRUE);
Expression b = ((XSLOtherwise)curr).compileSequenceConstructor(
exec, decl, curr.iterateAxis(Axis.CHILD));
if (b == null) {
b = Literal.makeEmptySequence();
}
try {