bool evaluatePredicate(const Expression& expression) { Value result(expression.evaluate()); // foo[3] means foo[position()=3] if (result.isNumber()) return EqTestOp(EqTestOp::OP_EQ, Function::create(ASCIILiteral("position")), std::make_unique<Number>(result.toNumber())).evaluate().toBoolean(); return result.toBoolean(); }
bool Predicate::evaluate() const { ASSERT(m_expr != 0); Value result(m_expr->evaluate()); // foo[3] means foo[position()=3] if (result.isNumber()) return EqTestOp(EqTestOp::OP_EQ, createFunction("position"), new Number(result.toNumber())).evaluate().toBoolean(); return result.toBoolean(); }