/** * Get the effective boolean value of the expression. This returns false if the value * is the empty sequence, a zero-length string, a number equal to zero, or the boolean * false. Otherwise it returns true. * * @param context The context in which the expression is to be evaluated * @return the effective boolean value * @throws net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the * expression */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { return value.effectiveBooleanValue(); }
/** * Get the effective boolean value of the expression. This returns false if the value * is the empty sequence, a zero-length string, a number equal to zero, or the boolean * false. Otherwise it returns true. * * @param context The context in which the expression is to be evaluated * @return the effective boolean value * @throws net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the * expression */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { return value.effectiveBooleanValue(); }
/** * Test if a literal has the effective boolean value true (or false) * * @param exp an expression * @param value true or false * @return true if the expression is a literal and the literal represents the boolean value given in the * second argument */ public static boolean hasEffectiveBooleanValue(Expression exp, boolean value) { if (exp instanceof Literal) { try { return value == ((Literal) exp).getValue().effectiveBooleanValue(); } catch (XPathException err) { return false; } } return false; }
/** * Test if a literal has the effective boolean value true (or false) * * @param exp an expression * @param value true or false * @return true if the expression is a literal and the literal represents the boolean value given in the * second argument */ public static boolean hasEffectiveBooleanValue(Expression exp, boolean value) { if (exp instanceof Literal) { try { return value == ((Literal) exp).getValue().effectiveBooleanValue(); } catch (XPathException err) { return false; } } return false; }
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { if (test instanceof Literal) { GroundedValue testVal = ((Literal) test).getValue(); // condition known statically, so we only need compile the code if true. // This can happen with expressions such as test="function-available('abc')". try { if (testVal.effectiveBooleanValue()) { return compileSequenceConstructor(exec, decl, true); } else { return null; } } catch (XPathException err) { // fall through to non-optimizing case } } Expression action = compileSequenceConstructor(exec, decl, true); if (action == null) { return null; } Expression[] conditions = {test}; Expression[] actions = {action}; Choose choose = new Choose(conditions, actions); choose.setInstruction(true); return choose; }
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { if (test instanceof Literal) { GroundedValue testVal = ((Literal) test).getValue(); // condition known statically, so we only need compile the code if true. // This can happen with expressions such as test="function-available('abc')". try { if (testVal.effectiveBooleanValue()) { return compileSequenceConstructor(exec, decl, true); } else { return null; } } catch (XPathException err) { // fall through to non-optimizing case } } Expression action = compileSequenceConstructor(exec, decl, true); if (action == null) { return null; } Expression[] conditions = {test}; Expression[] actions = {action}; Choose choose = new Choose(conditions, actions); choose.setInstruction(true); return choose; }
final boolean b; try { b = ((Literal) getCondition(i)).getValue().effectiveBooleanValue(); } catch (XPathException err) { err.setLocation(getLocation());
final boolean b; try { b = ((Literal) getCondition(i)).getValue().effectiveBooleanValue(); } catch (XPathException err) { err.setLocation(getLocation());