Package net.sf.saxon.xpath

Examples of net.sf.saxon.xpath.StaticError


                var.compile(this, slot);
            } catch (XPathException err) {
                if (err instanceof StaticError) {
                    throw (StaticError)err;
                } else {
                    throw new StaticError(err);
                }
            }
        }
    }
View Full Code Here


    public VariableDeclaration bindVariable(int fingerprint) throws StaticError {

        VariableDeclaration var = (VariableDeclaration)variables.get(new Integer(fingerprint));
        if (var==null) {
            throw new StaticError("Undeclared variable in query");
        } else {
            return var;
        }
    }
View Full Code Here

//            throw new XPathException.Static("Duplicate definition of function " +
//                    namePool.getDisplayName(fp));
//        }
        if (moduleNamespace != null &&
                namePool.getURICode(fp) != moduleNamespaceURICode) {
            throw new StaticError("Function " + namePool.getDisplayName(fp) +
                                            " is not defined in the module namespace"
                                            );
        }
        //functions.put(keyObj, function);
        functions.declareFunction(function);
View Full Code Here

        if (mod != null) {
            return mod;
        }

        if (locationURI == null) {
            throw new StaticError(
                    "import module must either specify a known namespace or a location");
        }
        // Resolve relative URI

        URL absoluteURL;
        if (baseURI==null) {    // no base URI available
            try {
                // the href might be an absolute URL
                absoluteURL = new URL(locationURI);
            } catch (MalformedURLException err) {
                // it isn't
                throw new StaticError("Cannot resolve URI (no base URI available)", err);
            }
        } else {
            try {
                absoluteURL = new URL(new URL(baseURI), locationURI);
            } catch (MalformedURLException err) {
                throw new StaticError("Cannot resolve relative URI", err);
            }
        }
        InputStream is;
        try {
            is = absoluteURL.openStream();
            BufferedReader reader = new BufferedReader(
                                        new InputStreamReader(is));

            StringBuffer sb = new StringBuffer(2048);
            char[] buffer = new char[2048];
            int actual;
            while (true) {
                actual = reader.read(buffer, 0, 2048);
                if (actual<0) break;
                sb.append(buffer, 0, actual);
            }
            reader.close();
            is.close();
            StaticQueryContext module = new StaticQueryContext(config);
            module.setBaseURI(absoluteURL.toString());
            module.setExecutable(executable);
            QueryParser qp = new QueryParser();
            qp.parseLibraryModule(sb.toString(), module);
            if (module.getModuleNamespace() == null) {
                throw new StaticError(
                        "Imported module must be a library module");
            }
            if (!module.getModuleNamespace().equals(namespaceURI)) {
                throw new StaticError(
                        "Imported module's namespace does not match requested namespace");
            }
            executable.addQueryLibraryModule(module);
            return module;
        } catch (java.io.IOException ioErr) {
            throw new StaticError(ioErr);
        }
    }
View Full Code Here

    * @throws net.sf.saxon.xpath.XPathException if the number of arguments is out of range
    */

    private int checkArgumentCount(int numArgs, int min, int max, String local) throws XPathException {
        if (min==max && numArgs != min) {
            throw new StaticError("Function saxon:" + local + " must have "
                    + min + pluralArguments(min));
        }
        if (numArgs < min) {
            throw new StaticError("Function saxon:" + local + " must have at least "
                    + min + pluralArguments(min));
        }
        if (numArgs > max) {
            throw new StaticError("Function saxon:" + local + " must have no more than "
                    + max + pluralArguments(max));
        }
        return numArgs;
    }
View Full Code Here

        if (argument.length > pos) {
            return;
            // this can happen during optimization, if the extra argument is already present
        }
        if (argument.length != pos) {
            throw new StaticError("Too few arguments in call to " + augmentedName + "() function");
        }
        Expression[] newArgs = new Expression[pos+1];
        System.arraycopy(argument, 0, newArgs, 0, argument.length);
        final RootExpression rootExpression = new RootExpression();
        ExpressionTool.copyLocationInfo(this, newArgs[pos]);
View Full Code Here

    public String getURIForPrefix(String prefix) throws XPathException {
        try {
            return element.getURIForPrefix(prefix, false);
        } catch (NamespaceException err) {
            throw new StaticError(err);
        }
    }
View Full Code Here

        String[] parts;
        try {
            parts = Name.getQNameParts(qname);
        } catch (QNameException err) {
            throw new StaticError(err.getMessage());
        }
        String prefix = parts[0];
        if (prefix.equals("")) {
            String uri = "";
View Full Code Here

            String uri = getURIForPrefix(parts[0]);

            return element.getPreparedStylesheet().
                                getStyleNodeFactory().isElementAvailable(uri, parts[1]);
        } catch (QNameException e) {
            throw new StaticError("Invalid element name. " + e.getMessage());
        }
    }
View Full Code Here

    public void declareFunction(XQueryFunction function) throws StaticError {
        int fp = function.getFunctionFingerprint();
        int arity = function.getNumberOfArguments();
        Long keyObj = new Long(((long)arity)<<32 + (long)fp);
        if (functions.get(keyObj) != null) {
            throw new StaticError("Duplicate definition of function " +
                    getNamePool().getDisplayName(fp));
        }
        functions.put(keyObj, function);
    }
View Full Code Here

TOP

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

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.