Search in sources :

Example 41 with XSBoolean

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method visit.

/**
 * visit instance of expression
 *
 * @param ioexp
 *            is the instance of expression.
 * @return a new function
 */
public Object visit(InstOfExpr ioexp) {
    // get the value
    ResultSequence rs = (ResultSequence) ioexp.left().accept(this);
    // get the sequence type
    SequenceType seqt = (SequenceType) ioexp.right();
    return ResultSequenceFactory.create_new(new XSBoolean(isInstanceOf(rs, seqt)));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) SequenceType(org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType)

Example 42 with XSBoolean

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method visit.

/**
 * visit if expression
 *
 * @param ifex
 *            is the if expression.
 * @return a ifex.then_clause().accept(this).
 */
public Object visit(IfExpr ifex) {
    ResultSequence test_res = do_expr(ifex.iterator());
    XSBoolean res = effective_boolean_value(test_res);
    if (res.value())
        return ifex.then_clause().accept(this);
    else
        return ifex.else_clause().accept(this);
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)

Example 43 with XSBoolean

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method visit.

/**
 * visit castable expression
 *
 * @param cexp
 *            is the castable expression.
 * @return a new function
 */
public Object visit(CastableExpr cexp) {
    boolean castable = false;
    try {
        CastExpr ce = new CastExpr((Expr) cexp.left(), (SingleType) cexp.right());
        visit(ce);
        castable = true;
    } catch (Throwable t) {
        castable = false;
    }
    return ResultSequenceFactory.create_new(new XSBoolean(castable));
}
Also used : XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) CastExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr)

Example 44 with XSBoolean

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method do_for_all.

// XXX ugly
// type: 0 = for [return == "correct"]
// 1 = for all [return false, return empty on true]
// 2 = there exists [return true, return empty on false]
private XSBoolean do_for_all(ListIterator iter, Expr finalexpr) {
    // we have more vars to bind...
    if (iter.hasNext()) {
        VarExprPair ve = (VarExprPair) iter.next();
        // evaluate binding sequence
        ResultSequence rs = (ResultSequence) ve.expr().accept(this);
        QName varname = ve.varname();
        try {
            for (Iterator i = rs.iterator(); i.hasNext(); ) {
                AnyType item = (AnyType) i.next();
                pushScope(varname, item);
                XSBoolean effbool = do_for_all(iter, finalexpr);
                popScope();
                // out what to do with it
                if (!effbool.value())
                    return XSBoolean.FALSE;
            }
        } finally {
            iter.previous();
        }
        return XSBoolean.TRUE;
    } else // we finally got to do the "last expression"
    {
        return effective_boolean_value((ResultSequence) finalexpr.accept(this));
    }
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Example 45 with XSBoolean

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method visit.

/**
 * visit schema element test.
 *
 * @param e
 *            is the schema element test.
 * @return a result sequence
 */
public Object visit(SchemaElemTest e) {
    // filter out all elements
    ResultSequence rs = kind_test((ResultSequence) ((Pair) _param)._two, ElementType.class);
    // match the name
    // XXX substitution groups
    QName name = e.name();
    for (Iterator i = rs.iterator(); i.hasNext(); ) {
        if (!name_test((ElementType) i.next(), name, "element"))
            i.remove();
    }
    // check the type
    TypeDefinition et = _sc.getTypeModel().lookupElementDeclaration(name.namespace(), name.local());
    for (Iterator i = rs.iterator(); i.hasNext(); ) {
        NodeType node = (NodeType) i.next();
        if (!derivesFrom(node, et)) {
            i.remove();
            continue;
        }
        XSBoolean nilled = (XSBoolean) node.nilled().first();
        // XXX or, in schema it is nillable
        if (nilled.value())
            i.remove();
    }
    return rs;
}
Also used : ElementType(org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair) TypeDefinition(org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition)

Aggregations

XSBoolean (org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)87 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)69 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)65 URL (java.net.URL)62 XSModel (org.apache.xerces.xs.XSModel)61 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)15 Iterator (java.util.Iterator)10 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)5 Collection (java.util.Collection)4 ListIterator (java.util.ListIterator)4 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)4 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)4 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)3 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)3 XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Schema (javax.xml.validation.Schema)2 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)2 ElementType (org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType)2