Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Expression


    /**
     * Test to ensure that an empty sequence is parsed and correctly evaluated
     * @throws Exception an error occurs
     */
    public void testEmptySequence() throws Exception {
        Expression exp = compileExpression("()");
        Value result = exp.evaluate(context);
        // result should be an empty sequence
        assertTrue("Result is not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence) result;
View Full Code Here


    /**
     * Test to ensure that an empty sequence inside an empty sequence is evaluated to empty sequence
     * @throws Exception an error occurs
     */
    public void testSequenceContainingEmptySequence() throws Exception {
        Expression exp = compileExpression("(())");
        Value result = exp.evaluate(context);
        // result should be an empty sequence
        assertTrue("Result is not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence) result;
View Full Code Here

    /**
     * Test to ensure that empty sequence item is removed after evaluation
     * @throws Exception an error occurs
     */
    public void testSequenceContainingEmptySequenceAndStrings() throws Exception {
        Expression exp = compileExpression("('a', (), 'b')");
        Value result = exp.evaluate(context);
        assertTrue("Result is not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence) result;

View Full Code Here

    /**
     * test that a variable reference can be parsed
     * @throws Exception if an error occurs
     */
    public void testVariableReferenceParse() throws Exception {
        Expression exp = parser.parse("$variable");
        assertNotNull("JXPathExpressionParser should be able to parse a " +
                      "variable reference expression", exp);
    }
View Full Code Here

    /**
     * Ensures that a qualified variable can be parsed 
     * @throws Exception if an error occurs
     */
    public void testQualifiedVariableReferenceParse() throws Exception {
        Expression exp = parser.parse("$prefix:myVar");
        assertNotNull("JXPathExpressionParser should be able to parse a " +
                      " qualified variable", exp);
    }
View Full Code Here

     *
     * @throws Exception
     *             if an error occurs
     */
    public void testArithmeticOperatorsParse() throws Exception {
        Expression exp = parser.parse("- 1 + 2 * 3 div 4 mod 5 - 6");
        assertNotNull("JXPathExpressionParser should be able to parse the "
                + " arithmetic operators", exp);
    }
View Full Code Here

    /**
     * Ensures that an xpath function expression can be parsed
     * @throws Exception if an error occurs
     */
    public void testFunctionParse() throws Exception {
        Expression exp = parser.parse("testFunction($myVar)");

        assertNotNull("JXPathExpressionParser should be able to parse a " +
                      "function expression", exp);

    }
View Full Code Here

        } else {
            ExpressionFactory factory = ExpressionFactory.getDefaultInstance();
            ExpressionParser parser = factory.createExpressionParser();
            try {
                // Parse, and evaluate the expression.
                Expression expression = parser.parse(expr);
                Value value = expression.evaluate(context);

                // Stream the value's contents into the process following the
                // dynamic process. Don't do it into the dynamic process as
                // that will cause any markup to get reevaluated.
                value.streamContents(getTargetProcess(dynamicProcess));
View Full Code Here

        items[1] = factory.createStringValue("b");
        items[2] = factory.createStringValue("c");    
        context.getCurrentScope().declareVariable(
                   new ImmutableExpandedName("", "myVar"),
                   factory.createSequence(items));
       Expression exp = compileExpression("$myVar=(\"a\",\"b\",\"c\")");
       Value result = exp.evaluate(context);   
 
       assertTrue("Sequence comparison failed :" +
           "'(\"a\",\"b\",\"c\")=(\"a\",\"d\")'",
            ((BooleanValue) result).asJavaBoolean());

       Expression exp2 = compileExpression("$myVar=(\"a\",\"d\")");
       Value result2 = exp2.evaluate(context);   

       assertTrue("Sequence comparison failed: " +
           "'(\"a\",\"b\",\"c\")=(\"a\",\"d\")'",
            ((BooleanValue) result2).asJavaBoolean());    
      
       Expression exp3 = compileExpression("2=(3, 4 div 2)");
       Value result3 = exp3.evaluate(context);   

       assertTrue("Sequence comparison failed : '2=(3, 4 div 2)'",
            ((BooleanValue) result3).asJavaBoolean());       
    }
View Full Code Here

                                value, exprPrefixes, exprSuffixes);
                XMLPipelineContext pipelineContext = getPipelineContext();
                try {
                    // parse the xpath

                    Expression expression = parser.parse(expressionStr);
                    // obtain the ExpressionContext from the PipelineContext
                    // the ExpressionContext is needed in order to evaluate the
                    // expression parsed
                    ExpressionContext expressionContext =
                            getPipelineContext().getExpressionContext();

                    // evaluate the experssion
                    Value result = expression.evaluate(expressionContext);
                    if (result.getSequence().getLength() == 0) {
                        // if the sequence is empty then we must remove the
                        // attriubute.
                        output.removeAttribute(i);
                    } else {
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.