Package net.sf.saxon.value

Examples of net.sf.saxon.value.CalendarValue


    public Item evaluateItem(XPathContext c) throws XPathException {
        AtomicValue av1 = (AtomicValue)argument[0].evaluateItem(c);
        if (av1==null) {
            return null;
        }
        CalendarValue in = (CalendarValue)av1.getPrimitiveValue();

        int nargs = argument.length;
        SecondsDurationValue tz = null;
        if (nargs==1) {
            // use the implicit timezone
            tz = (SecondsDurationValue)new DateTimeValue(c).getComponent(Component.TIMEZONE);
            return in.setTimezone(tz);
        } else {
            AtomicValue av2 = (AtomicValue)argument[1].evaluateItem(c);
            if (av2==null) {
                return in.removeTimezone();
            }
            tz = (SecondsDurationValue)av2.getPrimitiveValue();
            return in.setTimezone(tz);
        }
    }
View Full Code Here


    public Item evaluateItem(XPathContext context) throws XPathException {
        AtomicValue av1 = (AtomicValue)argument[0].evaluateItem(context);
        if (av1==null) {
            return null;
        }
        CalendarValue in = (CalendarValue)av1;

        int nargs = argument.length;
        DayTimeDurationValue tz;
        if (nargs==1) {
            return in.adjustTimezone(context.getImplicitTimezone());
        } else {
            AtomicValue av2 = (AtomicValue)argument[1].evaluateItem(context);
            if (av2==null) {
                return in.removeTimezone();
            }
            tz = (DayTimeDurationValue)av2;
            long microseconds = tz.getLengthInMicroseconds();
            if (microseconds%60000000 != 0) {
                XPathException err = new XPathException("Timezone is not an integral number of minutes");
                err.setErrorCode("FODT0003");
                err.setLocator(this);
                err.setXPathContext(context);
                throw err;
            }
            int tzminutes = (int)(microseconds / 60000000);
            if (Math.abs(tzminutes) > 14*60) {
                XPathException err = new XPathException("Timezone out of range (-14:00 to +14:00)");
                err.setErrorCode("FODT0003");
                err.setLocator(this);
                err.setXPathContext(context);
                throw err;
            }
            return in.adjustTimezone(tzminutes);
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.value.CalendarValue

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.