Package net.sf.saxon.xpath

Examples of net.sf.saxon.xpath.DynamicError


            return new Byte((byte) dval.longValue());
        } else if (target == char.class || target == Character.class) {
            if (value.length() == 1) {
                return new Character(value.charAt(0));
            } else {
                DynamicError de = new DynamicError("Cannot convert string to Java char unless length is 1");
                de.setXPathContext(context);
                de.setErrorCode("SAXON:0000");
                throw de;
            }
        } else {
            Object o = super.convertToJava(target, config, context);
            if (o == null) {
                DynamicError err = new DynamicError(
                        "Conversion of string to " + target.getName() + " is not supported");
                err.setXPathContext(context);
                err.setErrorCode("SAXON:0000");
                throw err;
            }
            return o;
        }
    }
View Full Code Here


        if (!(e instanceof Value)) {
            regexp = Matches.tryToCompile(argument, 1, 3);

            // check that it's not a pattern that matches ""
            if (regexp != null && regexp.matcher("").matches()) {
                DynamicError err = new DynamicError(
                        "The regular expression must not be one that matches a zero-length string");
                err.setErrorCode("FORX0003");
                throw err;
            }
        }

        return e;
View Full Code Here

            try {
                String javaRegex = RegexTranslator.translate(
                        arg1.getStringValue(), true);
                re = Pattern.compile(javaRegex, Matches.setFlags(flags));
            } catch (RegexTranslator.RegexSyntaxException err) {
                DynamicError de = new DynamicError(err);
                de.setErrorCode("FORX0002");
                de.setXPathContext(c);
                throw de;
            } catch (PatternSyntaxException err) {
                DynamicError de = new DynamicError(err);
                de.setErrorCode("FORX0002");
                de.setXPathContext(c);
                throw de;
            }

            // check that it's not a pattern that matches ""
            if (re.matcher("").matches()) {
View Full Code Here

                } else {
                    r = r.next;
                }
            }
            if (r==null) {
                DynamicError de = new DynamicError("Internal error: current template doesn't match current node");
                de.setXPathContext(context);
                de.setErrorCode("SAXON:0000");
                throw de;
            }
        }

        Rule specificRule = null;
View Full Code Here

    public DateTimeValue(DateValue date, TimeValue time) throws XPathException {
        SecondsDurationValue tz1 = (SecondsDurationValue)date.getComponent(Component.TIMEZONE);
        SecondsDurationValue tz2 = (SecondsDurationValue)time.getComponent(Component.TIMEZONE);
        zoneSpecified = (tz1 != null || tz2 != null);
        if (tz1 != null && tz2 != null && !tz1.equals(tz2)) {
            DynamicError err = new DynamicError("Supplied date and time are in different timezones");
            throw err;
        }
        // create a calendar that uses the timezone actually specified, or GMT otherwise
        //calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
        TimeZone zone;
View Full Code Here

            badDate("Non-numeric component");
        }
    }

    private void badDate(String msg) throws XPathException {
        DynamicError err = new DynamicError("Invalid dateTime value. " + msg);
        err.setErrorCode("FORG0001");
        throw err;
    }
View Full Code Here

          path = Navigator.getPath(node);
      } catch (Exception err) {
          // can fail if the node is incomplete, e.g. during whitespace stripping
      }

        DynamicError err = new DynamicError(
            "Ambiguous rule match for " + path + "\n" +
            "Matches both \"" + pat1 + "\" on line " + pat1.getLineNumber() + " of " + pat1.getSystemId() +
            "\nand \"" + pat2 + "\" on line " + pat2.getLineNumber() + " of " + pat2.getSystemId());
        c.recoverableError(err);
View Full Code Here

            return new StringValue(getStringValue());

        case Type.UNTYPED_ATOMIC:
            return new UntypedAtomicValue(getStringValue());
        default:
            DynamicError err = new DynamicError("Cannot convert dateTime to " +
                                     StandardNames.getDisplayName(requiredType));
            err.setXPathContext(context);
            err.setErrorCode("FORG0001");
            throw err;
        }
    }
View Full Code Here

            int months = ((MonthDurationValue)duration).getLengthInMonths();
            GregorianCalendar cal2 = (GregorianCalendar)calendar.clone();
            cal2.add(Calendar.MONTH, months);
            return new DateTimeValue(cal2, zoneSpecified);
        } else {
            DynamicError err = new DynamicError(
                    "DateTime arithmetic is not supported on xs:duration, only on its subtypes");
            err.setIsTypeError(true);
            throw err;
        }
    }
View Full Code Here

     * @throws XPathException for example if one value is a date and the other is a time
     */

    public SecondsDurationValue subtract(CalendarValue other) throws XPathException {
        if (!(other instanceof DateTimeValue)) {
            DynamicError err = new DynamicError(
                    "First operand of '-' is a dateTime, but the second is not");
            err.setIsTypeError(true);
            throw err;
        }
        return super.subtract(other);
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.xpath.DynamicError

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.