Search in sources :

Example 71 with QName

use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName 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)

Example 72 with QName

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

the class StaticNameResolver method visit.

/**
 * Validate a cast expression.
 *
 * @param cexp
 *            is the expression.
 * @return null.
 */
public Object visit(CastExpr cexp) {
    printBinExpr("CAST", cexp);
    SingleType st = (SingleType) cexp.right();
    QName type = st.type();
    javax.xml.namespace.QName qName = type.asQName();
    Function f = _sc.resolveFunction(qName, 1);
    if (f == null)
        reportError(new StaticFunctNameError("Type does not exist: " + type.toString()));
    cexp.set_function(f);
    _resolvedFunctions.add(qName);
    return null;
}
Also used : Function(org.eclipse.wst.xml.xpath2.api.Function) SingleType(org.eclipse.wst.xml.xpath2.processor.internal.ast.SingleType) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) StaticFunctNameError(org.eclipse.wst.xml.xpath2.processor.internal.StaticFunctNameError)

Example 73 with QName

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

the class StaticNameResolver method visit.

/**
 * Validate a function call.
 *
 * @param e
 *            is the expression.
 * @return null.
 */
public Object visit(FunctionCall e) {
    QName name = e.name();
    if (!expandFunctionQName(name))
        reportBadPrefix(name.prefix());
    javax.xml.namespace.QName qName = name.asQName();
    Function f = _sc.resolveFunction(qName, e.arity());
    if (f == null)
        reportError(new StaticFunctNameError("Function does not exist: " + name.string() + " arity: " + e.arity()));
    e.set_function(f);
    _resolvedFunctions.add(qName);
    visitExprs(e.iterator());
    return null;
}
Also used : Function(org.eclipse.wst.xml.xpath2.api.Function) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) StaticFunctNameError(org.eclipse.wst.xml.xpath2.processor.internal.StaticFunctNameError)

Example 74 with QName

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

the class DefaultStaticContext method function_exists.

/**
 * Check for existance of function.
 *
 * @param name
 *            function name.
 * @param arity
 *            arity of function.
 * @return true if function exists. False otherwise.
 */
public boolean function_exists(QName name, int arity) {
    String ns = name.namespace();
    if (!_functions.containsKey(ns))
        return false;
    FunctionLibrary fl = (FunctionLibrary) _functions.get(ns);
    return fl.function_exists(name, arity);
}
Also used : FnFunctionLibrary(org.eclipse.wst.xml.xpath2.processor.function.FnFunctionLibrary) FunctionLibrary(org.eclipse.wst.xml.xpath2.processor.internal.function.FunctionLibrary)

Example 75 with QName

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

the class DefaultStaticContext method function.

public Function function(QName name, int arity) {
    String ns = name.namespace();
    if (!_functions.containsKey(ns))
        return null;
    FunctionLibrary fl = (FunctionLibrary) _functions.get(ns);
    return fl.function(name, arity);
}
Also used : FnFunctionLibrary(org.eclipse.wst.xml.xpath2.processor.function.FnFunctionLibrary) FunctionLibrary(org.eclipse.wst.xml.xpath2.processor.internal.function.FunctionLibrary)

Aggregations

DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)77 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)77 URL (java.net.URL)76 XSModel (org.apache.xerces.xs.XSModel)76 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)76 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)76 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)42 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)21 Iterator (java.util.Iterator)18 Collection (java.util.Collection)17 ArrayList (java.util.ArrayList)13 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)11 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)10 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)10 ListIterator (java.util.ListIterator)9 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)9 XPathExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr)6 TypeDefinition (org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition)5 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)5 Schema (javax.xml.validation.Schema)4