Package net.sf.saxon.type

Examples of net.sf.saxon.type.ConversionResult


     * This value is calculated using the algorithm described in
     * [Appendix E Adding durations to dateTimes] of [XML Schema Part 2: Datatypes].
     * @throws XPathException
     */
    public static String add(XPathContext context, final String datetimeIn, final String durationIn) throws XPathException {
        ConversionResult cr0 = CalendarValue.makeCalendarValue(datetimeIn);
        if (cr0 instanceof ValidationFailure) {
            return "";
        }
        CalendarValue cv0 = (CalendarValue)cr0;
        if (specificity(cv0) < 0) {
            return "";
        }
        DateTimeValue v0 = cv0.toDateTime();
        ConversionResult cr1 = DurationValue.makeDuration(durationIn);
        if (cr1 instanceof ValidationFailure) {
            return "";
        }
        DurationValue v1 = (DurationValue)cr1;
        YearMonthDurationValue v1m =
View Full Code Here


        while (true) {
            Item it = nodes.next();
            if (it == null) {
                break;
            }
            ConversionResult cr = DurationValue.makeDuration(it.getStringValueCS());
            if (cr instanceof ValidationFailure) {
                return "";
            }
            tot = addDurationValues(tot, (DurationValue)cr, context);
            if (tot == null) {
View Full Code Here

     * are differently signed, then this sometimes results in durations that are impossible to express
     * in this syntax (e.g. 'P1M' + '-P1D'). In these cases, the function returns an empty string ('').
     */

    public String addDuration(XPathContext context, String duration0, String duration1) {
        ConversionResult dv0 = DurationValue.makeDuration(duration0);
        ConversionResult dv1 = DurationValue.makeDuration(duration1);
        if (dv0 instanceof ValidationFailure || dv1 instanceof ValidationFailure) {
            return "";
        }
        DurationValue result = addDurationValues((DurationValue)dv0, (DurationValue)dv1, context);
        return (result==null ? "" : result.getStringValue());
View Full Code Here

     * The number of seconds specified in the duration string must be less than 60;
     * the number of minutes must be less than 60; the number of hours must be less than 24.
     * @throws XPathException
     */
    public static String difference(XPathContext context, final String dateLeftIn, final String dateRightIn) throws XPathException {
        ConversionResult op0 = CalendarValue.makeCalendarValue(dateLeftIn);
        ConversionResult op1 = CalendarValue.makeCalendarValue(dateRightIn);
        if (op0 instanceof ValidationFailure || op1 instanceof ValidationFailure) {
            return "";
        }
        CalendarValue v0 = (CalendarValue)op0;
        CalendarValue v1 = (CalendarValue)op1;
View Full Code Here

     * for details.
     * If the argument is not in any of these formats, date:seconds returns NaN.
     * @throws XPathException
     */
    public static double seconds(XPathContext context, final String datetimeIn) throws XPathException {
        ConversionResult cr = CalendarValue.makeCalendarValue(datetimeIn);
        if (cr instanceof DateTimeValue || cr instanceof DateValue ||
                cr instanceof GYearValue || cr instanceof GYearMonthValue) {
            DateTimeValue dateTime = ((CalendarValue)cr).toDateTime();
            DayTimeDurationValue diff = dateTime.subtract(DateTimeValue.EPOCH, context);
            return diff.getLengthInSeconds();
View Full Code Here

        Item arg0 = argument[0].evaluateItem(context);
        if (arg0==null) {
            return DoubleValue.NaN;
        }
        if (arg0 instanceof BooleanValue || arg0 instanceof NumericValue) {
            ConversionResult result = ((AtomicValue)arg0).convert(BuiltInAtomicType.DOUBLE, true, context);
            if (result instanceof ValidationFailure) {
                return DoubleValue.NaN;
            } else {
                return (AtomicValue)result;
            }
View Full Code Here

        try {
            if (value==null) {
                return DoubleValue.NaN;
            }
            if (value instanceof BooleanValue || value instanceof NumericValue) {
                ConversionResult result = value.convert(BuiltInAtomicType.DOUBLE, true, null);
                if (result instanceof ValidationFailure) {
                    return DoubleValue.NaN;
                } else {
                    return (DoubleValue)result;
                }
View Full Code Here

        }
        if (((AtomicType)it).isBuiltInType()) {
            // TODO
        } else {
            Configuration config = ((ConstructedItemType)type).getProcessor().getUnderlyingConfiguration();
            ConversionResult result = new StringValue(lexicalForm).convert(
                    (AtomicType)it, true, config.getConversionContext());
            try {
                setValue(result.asAtomic());
            } catch (ValidationException e) {
                throw new SaxonApiException(e);
            }
        }
    }
View Full Code Here

        net.sf.saxon.type.ItemType it = type.getUnderlyingItemType();
        if (!it.isAtomicType()) {
            throw new SaxonApiException("Requested type is not atomic");
        }
        Configuration config = type.getProcessor().getUnderlyingConfiguration();
        ConversionResult result = new StringValue(value).convert((AtomicType)it, true, config.getConversionContext());
        try {
            return (XdmItem)wrap(result.asAtomic());
        } catch (ValidationException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

        net.sf.saxon.type.ItemType it = type.getUnderlyingItemType();
        if (!it.isAtomicType()) {
            throw new SaxonApiException("Requested type is not atomic");
        }
        Configuration config = type.getProcessor().getUnderlyingConfiguration();
        ConversionResult result = new StringValue(lexicalForm).convert(
                (AtomicType)it, true, config.getConversionContext());
        try {
            setValue(result.asAtomic());
        } catch (ValidationException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.type.ConversionResult

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.