Package net.sf.saxon.xpath

Examples of net.sf.saxon.xpath.DynamicError


            return new StringValue(getStringValue());
        case Type.UNTYPED_ATOMIC:
            return new UntypedAtomicValue(getStringValue());
        case Type.YEAR_MONTH_DURATION:
            if (days!=0 || hours!=0 || minutes!=0 || seconds!=0 || milliseconds!=0) {
                DynamicError err = new DynamicError(
                        "Cannot convert to yearMonthDuration because some components are non-zero");
                err.setXPathContext(context);
                err.setErrorCode("FORG0001");
                throw err;
            } else {
                return MonthDurationValue.fromMonths((years*12 + months) * (negative ? -1 : +1));
            }
        case Type.DAY_TIME_DURATION:
            if (years!=0 || months!=0) {
                DynamicError err = new DynamicError(
                        "Cannot convert to dayTimeDuration because some components are non-zero");
                err.setXPathContext(context);
                err.setErrorCode("FORG0001");
                throw err;
            } else {
                return SecondsDurationValue.fromSeconds(getLengthInSeconds());
            }
        default:
            DynamicError err = new DynamicError("Cannot convert duration to " +
                                     StandardNames.getDisplayName(requiredType));
            err.setXPathContext(context);
            err.setErrorCode("FORG0001");
            throw err;
        }
    }
View Full Code Here


        } else if (target==Object.class) {
            return getStringValue();
        } else {
            Object o = super.convertToJava(target, config, context);
            if (o == null) {
                DynamicError err = new DynamicError("Conversion of duration to " + target.getName() +
                        " is not supported");
                err.setXPathContext(context);
                err.setErrorCode("SAXON:0000");
            }
            return o;
        }
    }
View Full Code Here

    /**
    * Add two durations
    */

    public DurationValue add(DurationValue other, XPathContext context) throws XPathException {
        throw new DynamicError("Only subtypes of xs:duration can be added");
    }
View Full Code Here

    /**
    * Subtract two durations
    */

    public DurationValue subtract(DurationValue other, XPathContext context) throws XPathException{
        throw new DynamicError("Only subtypes of xs:duration can be subtracted");
    }
View Full Code Here

    /**
    * Multiply a duration by a number
    */

    public DurationValue multiply(double factor, XPathContext context) throws XPathException {
        throw new DynamicError("Only subtypes of xs:duration can be multiplied by a number");
    }
View Full Code Here

    /**
    * Divide a duration by a number
    */

    public DoubleValue divide(DurationValue other, XPathContext context) throws XPathException {
        throw new DynamicError("Only subtypes of xs:duration can be divided by another duration");
    }
View Full Code Here

            } else {
                return new BigIntegerValue(new BigInteger(t.toString()));
            }
        } catch (NumberFormatException err) {
            //err.printStackTrace();
            DynamicError e = new DynamicError("Cannot convert string " + Err.wrap(s, Err.VALUE) + " to an integer");
            e.setErrorCode("FORG0001");
            throw e;
        } catch (StringIndexOutOfBoundsException err2) {
            DynamicError e = new DynamicError("Cannot convert zero-length string to an integer");
            e.setErrorCode("FORG0001");
            throw e;
        }
    }
View Full Code Here

    private static void checkRange(long value, ItemType type) throws DynamicError {
        for (int i = 0; i < ranges.length; i += 3) {
            if (ranges[i] == ((AtomicType) type).getFingerprint()) {
                if (value < ranges[i + 1] || value > ranges[i + 2]) {
                    DynamicError err = new DynamicError("Value is out of range for type " + type.toString());
                    err.setErrorCode("FORG0001");
                    throw err;
                }
                return;
            }
        }
        DynamicError err = new DynamicError("No range information for type " + type.toString());
        err.setErrorCode("FORG0001");
        throw err;
    }
View Full Code Here

            case Type.UNTYPED_ATOMIC:
                return new UntypedAtomicValue(getStringValue());

            default:
                DynamicError err = new DynamicError("Cannot convert integer to " +
                        StandardNames.getDisplayName(requiredType));
                err.setXPathContext(context);
                err.setErrorCode("FORG0001");
                throw err;
        }
    }
View Full Code Here

                // same prefix and URI: ignore this duplicate
                return;
            }
          if ((nscode>>16) == (pendingNSList[i]>>16)) {
              if (rejectDuplicates) {
                  DynamicError err = new DynamicError("Cannot create two namespace nodes with the same name");
                    err.setErrorCode("XT0430");
                    throw err;
              } else {
                // same prefix, do a quick exit
                return;
            }
          }
        }

        // It is an error to output a namespace node for the default namespace if the element
        // itself is in the null namespace, as the resulting element could not be serialized

        if ( elementIsInNullNamespace && ((nscode>>16) == 0) && ((nscode&0xffff)!=0)) {
            DynamicError err = new DynamicError(
                    "Cannot output a namespace node for the default namespace when the element is in no namespace");
            err.setErrorCode("XT0440");
            throw err;
        }

        // if it's not a duplicate namespace, add it to the list for this start tag
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.