Package xbird.xquery

Examples of xbird.xquery.DynamicError


        }
        final Pattern compiled;
        try {
            compiled = Pattern.compile(pattern, flags);
        } catch (PatternSyntaxException pse) {
            throw new DynamicError("err:FORX0002", "Invalid pattern: " + pattern);
        }
        if(compiled.matcher("").matches()) {
            // An error is raised [err:FORX0003] if the pattern matches a zero-length string,
            // that is, if the expression fn:matches("", $pattern, $flags) returns true.
            // It is not an error, however, if a captured substring is zero-length.
            throw new DynamicError("err:FORX0003", "Specified pattern is illegally matched to zero-length string: "
                    + pattern);
        }
        Matcher matcher = compiled.matcher(input);
        final String replaced = matcher.replaceAll(replacement);
        return XString.valueOf(replaced);
View Full Code Here


                    char next = replacement.charAt(i + 1);
                    if(Character.isDigit(next)) {
                        continue;
                    }
                }
                throw new DynamicError("err:FORX0004", "Invalid replacement expr: " + replacement);
            } else if(c == '\\') {
                if(len >= i + 1) {
                    char next = replacement.charAt(i + 1);
                    // An error is raised [err:FORX0004] if the value of $replacement contains
                    // a "\" character that is not part of a "\\" pair, unless it is immediately
                    // followed by a "$" character.
                    if(next == '\\' || next == '$') {
                        continue;
                    }
                }
                throw new DynamicError("err:FORX0004", "Invalid replacement expr: " + replacement);
            }
        }
    }
View Full Code Here

            // If $arg is not specified, returns the value of the base-uri property
            // of the context item (.)
            final Item contextItem = dynEnv.contextItem();
            if(argv == null) {
                if(contextItem == null) {
                    throw new DynamicError("err:XPDY0002", "Context Item is not set");
                } else {
                    if(!(contextItem instanceof XQNode)) {
                        throw new DynamicError("err:XPTY0004", "Context item is not a node: "
                                + contextItem.getClass().getName());
                    }
                }
            } else if(argv.isEmpty()) {// If $arg is the empty sequence, the empty sequence is returned.
                return ValueSequence.EMPTY_SEQUENCE;
            }
        }
        Item it = argv.getItem(0);
        if(it instanceof SingleCollection) {
            final Sequence<? extends Item> src = ((SingleCollection) it).getSource();
            final IFocus<? extends Item> itor = src.iterator();
            if(!itor.hasNext()) {
                itor.closeQuietly();
                return ValueSequence.EMPTY_SEQUENCE;
            }
            it = itor.next();
            if(itor.hasNext()) {
                itor.closeQuietly();
                throw new DynamicError("err:XPTY0004", "Context item is not a node: " + src);
            }
            itor.closeQuietly();
        }
        if(!(it instanceof XQNode)) {
            if(it.isEmpty()) {
                return ValueSequence.EMPTY_SEQUENCE;
            } else {
                throw new DynamicError("err:XPTY0004", "Item was not a node: "
                        + it.getClass().getName());
            }
        }
        final XQNode node = (XQNode) it;
        final byte nodekind = node.nodeKind();
View Full Code Here

                if(relative.isAbsolute()) {// If $relative is an absolute URI reference, it is returned unchanged.
                    return AnyURIValue.valueOf(relative);
                }
            }
        } catch (URISyntaxException e) {
            throw new DynamicError("err:FORG0002", "Invalid URI form: " + relativeStr);
        }
        final URI baseUri;
        final int arglen = argv.size();
        if(arglen == 2) {
            Item secondItem = argv.getItem(1);
            String baseStr = secondItem.stringValue();
            baseUri = URI.create(baseStr);
        } else {
            baseUri = dynEnv.getStaticContext().getBaseURI();
            if(baseUri == null) {
                throw new DynamicError("err:FONS0005", "BaseUri is not set in the static context.");
            }
        }
        if(relative == null) {// If $relative is the zero-length string, returns the value of the base-uri property.
            return AnyURIValue.valueOf(baseUri);
        }
View Full Code Here

        Item secondItem = argv.getItem(1);
        final String qname = ((XString) secondItem).getValue();
        final String paramUri;
        if(firstItem.isEmpty()) {
            if(qname.indexOf(':') != -1) {
                throw new DynamicError("err:FOCA0002", "Invalid qname: " + qname);
            }
            paramUri = XMLUtils.NULL_NS_URI;
        } else {
            paramUri = ((XString) firstItem).getValue();
        }
        final QualifiedName ret;
        try {
            ret = QNameUtil.parse(qname, paramUri);
        } catch (Throwable e) {
            throw new DynamicError("err:FOCA0002", "Incorrect lexical form for xs:QName: " + qname);
        }
        return new QNameValue(ret);
    }
View Full Code Here

    public static URI resolveURI(String relativeUri, StaticContext staticEnv)
            throws XQueryException {
        assert (relativeUri != null && staticEnv != null);
        URI baseUri = staticEnv.getBaseURI();
        if(baseUri == null) {
            throw new DynamicError("err:FONS0005", "BaseUri is not set in the static context.");
        }
        return resolveURI(relativeUri, baseUri);
    }
View Full Code Here

        if(argv == null) {
            // If no argument is supplied, $arg defaults to the string value of the context item (.).
            // If no argument is supplied and the context item is undefined an error is raised: [err:XPDY0002].
            Item contextItem = dynEnv.contextItem();
            if(contextItem == null) {
                throw new DynamicError("err:XPDY0002", "ContextItem is not set");
            }
            String sv = contextItem.stringValue();
            // If the value of $arg is the empty sequence, the xs:integer 0 is returned.
            return XInteger.valueOf(sv.length());
        }
View Full Code Here

            if(argItor.hasNext()) {
                final Item first = argItor.next();
                assert (first != null);
                if(argItor.hasNext()) {
                    // Returns $arg if it contains one or more items. Otherwise, raises an error [err:FORG0004].
                    throw new DynamicError("err:FORG0004", "Invalid result sequence type was detected, $arg contains one or more items: "
                            + arg.getType());
                }
            }
        }
        return arg;
View Full Code Here

            normed = Normalizer.normalize(arg, Normalizer.NFKC);
        } else if("NFKD".equalsIgnoreCase(nform) || "FULLY-NORMALIZED".equalsIgnoreCase(nform)) {
            normed = Normalizer.normalize(arg, Normalizer.NFKD);
        } else {
            // TODO "FULLY-NORMALIZED"
            throw new DynamicError("err:FOCH0003", "Unsupported normalizationForm: " + nform);
        }
        return XString.valueOf(normed);
    }
View Full Code Here

                        ;
                    }
                }
                is = conn.getInputStream();
            } catch (IOException e) {
                throw new DynamicError("Openning a document failed: " + unescaped, e);
            }
            final boolean resolveEntity = unescaped.startsWith("http");
            final DocumentTableModel dtm = new DocumentTableModel(parseAsHtml, resolveEntity);
            try {
                dtm.loadDocument(is, dynEnv);
            } catch (XQueryException e) {
                throw new DynamicError("loading a document failed: " + unescaped, e);
            }
            xqdoc = dtm.documentNode();
            xqdoc.setDocumentUri(unescaped);
            _sharedCache.put(docurl, xqdoc);
        }
View Full Code Here

TOP

Related Classes of xbird.xquery.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.