Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Expression


                result);
        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "mySequence"),
                factory.createSequence(items));

        Expression exp = compileExpression("$myVar = $mySequence");

        try {
            exp.evaluate(context);

            fail("Should have had an exception thrown");
        } catch (ExpressionException e) {
            // Expected condition
            System.out.println(e);
View Full Code Here


                factory.createSequence(left));
        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "right"),
                factory.createSequence(right));

        Expression exp = compileExpression("$left = $right");
        Value result = exp.evaluate(context);

        assertTrue("Sequence comparison failed",
                   ((BooleanValue) result).asJavaBoolean());
    }
View Full Code Here

                factory.createSequence(left));
        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "right"),
                factory.createSequence(right));

        Expression exp = compileExpression("$left != $right");
        Value result = exp.evaluate(context);

        // the sequences are not equal as the first item in both
        // sequences are not equal. Note these same 2 sequences
        // are both equal and not equal.
        assertTrue("Sequence comparison failed",
View Full Code Here

    public void testEqualityEvaluate() throws Exception {
        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "myVar"),
                result);

        Expression exp = compileExpression("$myVar = \"" +
                                           result.stringValue().
                                           asJavaString() + "\"");
        Value result = exp.evaluate(context);

        assertTrue("Equality expression should result in a boolean value",
                   result instanceof BooleanValue);
        assertTrue("Equality expression result should be true",
                   ((BooleanValue) result).asJavaBoolean());
View Full Code Here

     */
    private void doTestOperatorExpression(String operator,
                                          String expression,
                                          boolean expected) throws Exception {
        // compile and evalute the expression
        Expression exp = compileExpression(expression);
        Value result = exp.evaluate(context);

        // check the result type
        assertTrue(operator + " expression should result in a boolean value",
                   result instanceof BooleanValue);

View Full Code Here

        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "myVar"),
                one);

        Expression exp = compileExpression("not(3 < $myVar)");

        Value result = exp.evaluate(context);

        assertTrue("fn:not expression should result in a boolean value",
                   result instanceof BooleanValue);

        assertTrue("fn:not expression result should be true",
View Full Code Here

     * Test for the not function in expressions
     * @throws Exception if an error occurs
     */
    public void testNotWithTrue() throws Exception {

        Expression exp = compileExpression("not(true())");

        Value result = exp.evaluate(context);

        assertTrue("fn:not expression should result in a boolean value",
                   result instanceof BooleanValue);

        assertFalse("fn:not expression result should be false",
View Full Code Here

    /**
     * Test the boolean function with a String value argument.
     * @throws Exception if an error occurs
     */
    public void testBooleanStringArg() throws Exception {
        Expression exp = compileExpression("boolean(\"1\")");

        Value result = exp.evaluate(context);

        assertTrue("fn:boolean should result in a boolean value",
                   result instanceof BooleanValue);

        assertTrue("fn:boolean expression result should be true",
View Full Code Here

        Sequence seq = factory.createDoubleValue(1.0).getSequence();
        context.getCurrentScope().declareVariable(
                        new ImmutableExpandedName("", "myVar"),
                        seq);

        Expression exp = compileExpression("boolean($myVar)");

        Value result = exp.evaluate(context);

        assertTrue("fn:boolean should result in a boolean value",
                   result instanceof BooleanValue);

        assertTrue("fn:boolean expression result should be true",
View Full Code Here

            // as we may need to remove the attribute.
            index = attributes.getIndex(exprAttributeURI, "expr");
            if (index != -1) {
                String value = attributes.getValue(index);
                try {
                    Expression expression = parser.parse(value);

                    // obtain the ExpressionContext from the PipelineContext
                    // the ExpressionContext is needed in order to evaluate the
                    // expression parsed
                    ExpressionContext expressionContext =
                            pipelineContext.getExpressionContext();

                    // Evaluate the expression and cast to a boolean.
                    boolean result = PipelineExpressionHelper.fnBoolean(
                            expression.evaluate(
                                    expressionContext).getSequence())
                            .asJavaBoolean();

                    if (!result) {
                        // The expression evaluated to false so ignore this
View Full Code Here

TOP

Related Classes of com.volantis.xml.expression.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.