Package net.sf.saxon.xpath

Examples of net.sf.saxon.xpath.DynamicError


                    return new IntegerValue(value * ((IntegerValue) other).value);
                case Token.IDIV:
                    try {
                        return new IntegerValue(value / ((IntegerValue) other).value);
                    } catch (ArithmeticException err) {
                        DynamicError e;
                        if ("/ by zero".equals(err.getMessage())) {
                            e = new DynamicError("Integer division by zero");
                            e.setErrorCode("FOAR0001");
                        } else {
                            e = new DynamicError("Integer division failure", err);
                        }
                        e.setXPathContext(context);
                        throw e;
                    }
                case Token.DIV:
                    // the result of dividing two integers is a decimal; but if
                    // one divides exactly by the other, we implement it as an integer
                    long quotient = ((IntegerValue) other).value;
                    if (quotient == 0) {
                        DynamicError err = new DynamicError("Integer division by zero");
                        err.setXPathContext(context);
                        err.setLocator(ExpressionTool.getLocator(this));
                        err.setErrorCode("FORG0001");
                        throw err;
                    }
                    if (value % quotient == 0) {
                        return new IntegerValue(value / quotient);
                    }
View Full Code Here


                    pendingAttValue[a] = value;
                    pendingAttLocation[a] = locationId;
                    pendingAttProp[a] = properties;
                    return;
                } else {
                    DynamicError err = new DynamicError("Duplicate attribute: " +
                            namePool.getDisplayName(nameCode));
                    err.setErrorCode("XQ0025");
                    throw err;
                }
            }
        }
View Full Code Here

                        context.getController().getConfiguration().getHostLanguage() != Configuration.XQUERY) ||
                error.getLocator().getLineNumber()==-1) {
            // If the exception has no location information, construct a new
            // exception containing the required information
            try {
                DynamicError de = new DynamicError(error.getMessage(),
                                                loc,
                                                error.getException());
                if (error instanceof DynamicError) {
                    de.setErrorCode(error.getErrorCode());
                    if (((DynamicError)error).getXPathContext()==null) {
                        de.setXPathContext(context);
                    } else {
                        de.setXPathContext(((DynamicError)error).getXPathContext());
                    }
                }
                return de;
            } catch (Exception secondaryError) {
                // currently happens when running XQuery
View Full Code Here

        } else if (item instanceof AtomicValue) {
            if (previousAtomic) {
                characters(" ", locationId, 0);
            }
            if (item instanceof QNameValue) {
                DynamicError err = new DynamicError("Cannot add a QName value to the content of an element");
                err.setErrorCode("XT0380");
                throw err;
            }
            characters(item.getStringValue(), locationId, 0);
            previousAtomic = true;
        } else if (item instanceof DocumentInfo) {
View Full Code Here

        } else if (target == BigDecimal.class) {
            return new BigDecimal(value);
        } else {
            Object o = super.convertToJava(target, config, context);
            if (o == null) {
                throw new DynamicError("Conversion of integer to " + target.getName() +
                        " is not supported");
            }
            return o;
        }
    }
View Full Code Here

    * @param controller The controller of the transformation
    * @return an exception containing details of the dynamic error
    */

    protected XPathException dynamicError(String message, Controller controller) {
        return new DynamicError(message, getSourceLocator());
    }
View Full Code Here

                return collator.compare(getStringValue(), ((StringValue)other).getStringValue());
        } else if (other instanceof AtomicValue) {
            try {
                AtomicValue conv = convert((AtomicType)((Value)other).getItemType(), null);
                if (!(conv instanceof Comparable)) {
                    throw new DynamicError("Type " + ((Value)other).getItemType() + " is not ordered");
                }
                return ((Comparable)conv).compareTo(other);
            } catch (XPathException err) {
                throw new ClassCastException("Cannot convert untyped atomic value '" + getStringValue()
                            + "' to type " + ((Value)other).getItemType());
View Full Code Here

    protected String checkContent(String comment, XPathContext context) throws DynamicError {
        while(true) {
            int hh = comment.indexOf("--");
            if (hh < 0) break;
            DynamicError err = new DynamicError("Invalid characters (--) in comment", this);
            err.setErrorCode("XT0950");
            // TODO: XQuery error code to be assigned (see also below)
            err.setXPathContext(context);
            context.getController().recoverableError(err);
            comment = comment.substring(0, hh+1) + ' ' + comment.substring(hh+1);
        }
        if (comment.length()>0 && comment.charAt(comment.length()-1)=='-') {
            DynamicError err = new DynamicError("Invalid character (-) at end of comment", this);
            err.setErrorCode("XT0950");
            err.setXPathContext(context);
            context.getController().recoverableError(err);
            comment = comment + ' ';
        }       
        return comment;
    }
View Full Code Here

        boolean wasSupplied = b.useGlobalParameter(getVariableFingerprint(), this);
        if (wasSupplied) {
            return b.getGlobalVariableValue(this);
        } else {
            if (isRequiredParam()) {
                DynamicError e = new DynamicError("No value supplied for required parameter $" +
                        context.getController().getNamePool().getDisplayName(getVariableFingerprint()));
                e.setXPathContext(context);
                e.setLocator(getSourceLocator());
                e.setErrorCode("XT0050");
                throw e;
                // TODO: we aren't reporting this error if the required parameter is never referenced
            }

            // This is the first reference to a global variable; try to evaluate it now.
            // But first set a flag to stop looping. This flag is set in the Bindery because
            // the VariableReference itself can be used by multiple threads simultaneously

            try {
                b.setExecuting(this, true);
                //XPathContext c2 = context.newCleanContext();
                Value value = getSelectValue(context);
                b.defineGlobalVariable(this, value);
                b.setExecuting(this, false);
                return value;

            } catch (XPathException err) {
                if (err instanceof XPathException.Circularity) {
                    DynamicError e = new DynamicError("Circular definition of parameter " + getVariableName());
                    e.setXPathContext(context);
                    e.setErrorCode("XT0640");
                    throw e;
                } else {
                    throw err;
                }
            }
View Full Code Here

                setOutputStream(new FileOutputStream(file));
                // Set the outputstream in the StreamResult object so that the
                // call on OutputURIResolver.close() can close it
                streamResult.setOutputStream(outputStream);
            } catch (FileNotFoundException fnf) {
                throw new DynamicError(fnf);
            } catch (URISyntaxException use) {
                throw new DynamicError(use);
            }
        }
    }
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.