Search in sources :

Example 11 with DynamicError

use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.

the class FnMinutesFromDateTime method minutes_from_date_time.

/**
 * Minutes-from-DateTime operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:minutes-from-dateTime operation.
 */
public static ResultSequence minutes_from_date_time(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSDateTime dt = (XSDateTime) arg1.first();
    int res = dt.minute();
    return new XSInteger(BigInteger.valueOf(res));
}
Also used : XSDateTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) Collection(java.util.Collection)

Example 12 with DynamicError

use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.

the class FnMonthFromDateTime method month_from_date_time.

/**
 * Month-from-DateTime operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:month-from-dateTime operation.
 */
public static ResultSequence month_from_date_time(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSDateTime dt = (XSDateTime) arg1.first();
    int res = dt.month();
    return new XSInteger(BigInteger.valueOf(res));
}
Also used : XSDateTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) Collection(java.util.Collection)

Example 13 with DynamicError

use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.

the class FnName method name.

/**
 * Name operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @param context
 *            Dynamic context.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:name operation.
 */
public static ResultSequence name(Collection args, EvaluationContext ec) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    // get arg
    ResultSequence arg1 = null;
    if (cargs.isEmpty()) {
        if (ec.getContextItem() == null)
            throw DynamicError.contextUndefined();
        else {
            arg1 = ResultBuffer.wrap(ec.getContextItem());
        }
    } else {
        arg1 = (ResultSequence) cargs.iterator().next();
    }
    if (arg1.empty()) {
        return new XSString("");
    }
    NodeType an = (NodeType) arg1.first();
    QName name = an.node_name();
    String sname = "";
    if (name != null)
        sname = name.getStringValue();
    return new XSString(sname);
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) Collection(java.util.Collection) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 14 with DynamicError

use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.

the class FnZeroOrOne method zero_or_one.

/**
 * Zero-or-One operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:zero-or-one operation.
 */
public static ResultSequence zero_or_one(Collection args) throws DynamicError {
    assert args.size() == 1;
    // get args
    Iterator citer = args.iterator();
    ResultSequence arg = (ResultSequence) citer.next();
    if (arg.size() > 1)
        throw DynamicError.more_one_item(null);
    return arg;
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Iterator(java.util.Iterator)

Example 15 with DynamicError

use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.

the class FsGe method fs_ge_value.

/**
 * Greater than or equal to operation on the values of the arguments.
 *
 * @param args
 *            input arguments.
 * @param dc
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of the operation.
 */
public static ResultSequence fs_ge_value(Collection args, DynamicContext dc) throws DynamicError {
    ResultSequence greater = FsGt.fs_gt_value(args, dc);
    if (((XSBoolean) greater.first()).value())
        return greater;
    ResultSequence equal = FsEq.fs_eq_value(args, dc);
    if (((XSBoolean) equal.first()).value())
        return equal;
    return ResultSequenceFactory.create_new(new XSBoolean(false));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)

Aggregations

DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)8211 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)8203 URL (java.net.URL)8194 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)8193 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)8193 XSModel (org.apache.xerces.xs.XSModel)8192 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)144 Schema (javax.xml.validation.Schema)100 Collection (java.util.Collection)81 DefaultEvaluator (org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator)72 Evaluator (org.eclipse.wst.xml.xpath2.processor.Evaluator)72 XPath (org.eclipse.wst.xml.xpath2.processor.ast.XPath)72 DynamicContext (org.eclipse.wst.xml.xpath2.processor.DynamicContext)71 Iterator (java.util.Iterator)70 Item (org.eclipse.wst.xml.xpath2.api.Item)68 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)54 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)47 XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)25 XSAnyURI (org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI)22 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)20