Package net.sf.saxon.xpath

Examples of net.sf.saxon.xpath.StaticError


    NamePool namePool = getTargetNamePool();
        String[] parts;
        try {
            parts = Name.getQNameParts(qname);
        } catch (QNameException err) {
            throw new StaticError(err.getMessage());
        }
    String prefix = parts[0];
        if ("".equals(prefix)) {
      return namePool.allocate(prefix, (short)0, qname);

        } else {

            String uri = getURIForPrefix(prefix, false);
            if (NamespaceConstant.isReserved(uri)) {
                StaticError err = new StaticError("Namespace prefix " + prefix + " refers to a reserved namespace");
                err.setErrorCode("XT0080");
                throw err;
            }
      return namePool.allocate(prefix, uri, parts[1]);
        }
View Full Code Here


        }
    }

    protected void compileError(String message)
    throws TransformerConfigurationException {
        StaticError tce = new StaticError(message);
        tce.setLocator(this);
        compileError(tce);
    }
View Full Code Here

     * @param errorCode the error code. May be null if not known or not defined
     * @throws TransformerConfigurationException
     */
    protected void compileError(String message, String errorCode)
    throws TransformerConfigurationException {
        StaticError tce = new StaticError(message);
        tce.setErrorCode(errorCode);
        tce.setLocator(this);
        compileError(tce);
    }
View Full Code Here

    */

    public XSLVariableDeclaration bindVariable(int fingerprint) throws StaticError {
        XSLVariableDeclaration binding = getVariableBinding(fingerprint);
        if (binding==null) {
            throw new StaticError("Variable " + getTargetNamePool().getDisplayName(fingerprint) + " has not been declared");
        }
        return binding;
    }
View Full Code Here

        if (name.equals("parent"))                  return PARENT;
        if (name.equals("preceding"))               return PRECEDING;
        if (name.equals("preceding-sibling"))       return PRECEDING_SIBLING;
        if (name.equals("self"))                    return SELF;
        // preceding-or-ancestor cannot be used in an XPath expression
        throw new StaticError("Unknown axis name: " + name);
    }
View Full Code Here

            if ((i0 < 0 || i2 < i0) && (i8 < 0 || i2 < i8)) {   // found end of string
                addStringComponent(components, avt, last, i2);
                last = i2;
                break;
            } else if (i0 >= 0 && i0 != i1 && i8 < i0) {   // found a "{" with no matching "}"
                StaticError err = new StaticError(
                        "Unmatched opening curly brace in attribute value template \"" + avt.substring(0,i2) + "\"");
                err.setErrorCode("XT0350");
                throw err;
            } else if (i8 >= 0 && (i0 < 0 || i8 < i0)) {             // found a "}"
                if (i8 != i9) {                        // a "}" that isn't a "}}"
                    StaticError err = new StaticError(
                            "Closing curly brace in attribute value template \"" + avt.substring(0,i2) + "\" must be doubled");
                    err.setErrorCode("XT0360");
                    throw err;
                }
                addStringComponent(components, avt, last, i8 + 1);
                last = i8 + 2;
            } else if (i1 >= 0 && i1 == i0) {              // found a doubled "{{"
View Full Code Here

                        uri = env.getURIForPrefix(prefix);
                    }
                    int fingerprint = env.getNamePool().allocate(prefix, uri, parts[1]) & 0xfffff;
                    b = env.getFunctionLibrary().isAvailable(fingerprint, uri, parts[1], (int)arity);
                } catch (QNameException e) {
                    throw new StaticError(e.getMessage());
                }
                break;
        }
        return BooleanValue.get(b);
    }
View Full Code Here

    public Expression bind(int nameCode, String uri, String local, Expression[] staticArgs)
            throws XPathException {
        if (uri.equals(NamespaceConstant.FN)) {
            StandardFunction.Entry entry = StandardFunction.getFunction(local);
            if (entry == null) {
                throw new StaticError("Unknown system function " + local + "()");
            }
            Class functionClass = entry.implementationClass;
            SystemFunction f;
            try {
                f = (SystemFunction)functionClass.newInstance();
            } catch (Exception err) {
                throw new AssertionError("Failed to load system function: " + err.getMessage());
            }
            f.setDetails(entry);
            f.setFunctionNameCode(nameCode);
            f.setArguments(staticArgs);
            checkArgumentCount(staticArgs.length, entry.minArguments, entry.maxArguments, local);
            if (f instanceof XSLTFunction && !allowXSLTFunctions) {
                throw new StaticError("Cannot use the " + local + "() function in a non-XSLT context");
            }
            return f;
        } else {
            return null;
        }
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 " + local + " must have "
                    + min + pluralArguments(min));
        }
        if (numArgs < min) {
            throw new StaticError("Function " + local + " must have at least "
                    + min + pluralArguments(min));
        }
        if (numArgs > max) {
            throw new StaticError("Function " + local + " must have no more than "
                    + max + pluralArguments(max));
        }
        return numArgs;
    }
View Full Code Here

        if (argument.length==3 && argument[2] instanceof StringValue) {
            // common case, decimal format name is supplied as a string literal

            String qname = ((StringValue)argument[2]).getStringValue();
            if (!Name.isQName(qname)) {
                throw new StaticError("Decimal format name '" + qname + "' is not a valid QName");
            }
            try {
                String[] parts = Name.getQNameParts(qname);
                dfLocalName = parts[1];
                dfURI = env.getURIForPrefix(parts[0]);
            } catch (QNameException e) {
                throw new StaticError(e.getMessage());
            }
        } else {
            // we need to save the namespace context
            nsContext = env.getNamespaceResolver();
        }
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.