Package org.pdf4j.saxon.trans

Examples of org.pdf4j.saxon.trans.XPathException


                    if (comparer.compare(node, first) < 0) {
                        first = node;
                    }
                }
            } else {
                XPathException e = new XPathException("Operand of after() contains an item that is not a node");
                e.setXPathContext(context);
                throw e;
            }
        }

        // Filter ns1 to select nodes that come after this one
View Full Code Here


     */

    public static String path(XPathContext c) throws XPathException {
        Item item = c.getContextItem();
        if (item == null) {
            XPathException e = new XPathException("The context item for saxon:path() is not set");
            e.setXPathContext(c);
            throw e;
        }
        if (item instanceof NodeInfo) {
            return Navigator.getPath((NodeInfo)item);
        } else {
View Full Code Here

        if (name == null) {
            return null;
        }
        Item pi = c.getContextItem();
        if (pi == null) {
            XPathException e = new XPathException("The context item for saxon:getPseudoAttribute() is not set");
            e.setXPathContext(c);
            throw e;
        }
        // we'll assume it's a PI, it doesn't matter if it isn't...
        String val = ProcInstParser.getPseudoAttribute(pi.getStringValue(), name);
        if (val == null) {
View Full Code Here

            if (UTF16.isHighSurrogate(ch32)) {
                char low = array[c++];
                ch32 = UTF16.combinePair((char)ch32, low);
            }
            if (!checker.isValidChar(ch32)) {
                XPathException err = new XPathException("The byte sequence contains a character not allowed by XML (hex " +
                        Integer.toHexString(ch32) + ')');
                err.setErrorCode("XTDE1180");
                throw err;
            }
        }
    }
View Full Code Here

    public static NodeInfo namespaceNode(XPathContext context, String prefix, String uri) throws XPathException {
        if (prefix == null) {
            prefix = "";
        } else if (!(prefix.length() == 0 || context.getConfiguration().getNameChecker().isValidNCName(prefix))) {
            throw new XPathException("Namespace prefix " + Err.wrap(prefix) + " is not a valid NCName");
        }
        if (uri == null || uri.length() == 0) {
            throw new XPathException("URI of namespace node must not be empty");
        }
        final NamePool namePool = context.getNamePool();
        Orphan node = new Orphan(context.getConfiguration());
        node.setNodeKind(Type.NAMESPACE);
        node.setNameCode(namePool.allocate("", "", prefix));
View Full Code Here

     */
    public static DateTimeValue lastModified(XPathContext c) throws XPathException {
        // Original author Zdenek Wagner [zdenek.wagner@gmail.com] contributed 2007-10-22
        Item item = c.getContextItem();
        if (item == null) {
            XPathException e = new XPathException("The context item for lastModified() is not set");
            e.setXPathContext(c);
            throw e;
        }
        if (item instanceof NodeInfo) {
            return lastModified(c, (NodeInfo)item);
        } else {
View Full Code Here

        URI absoluteURI;
        try {
            absoluteURI = new URI(fileURI);
        } catch (URISyntaxException e) {
            if (debug) {
                throw new XPathException(e);
            }
            return null;
        }
        if (!absoluteURI.isAbsolute()) {
            if (debug) {
                throw new XPathException("Supplied URI " + fileURI + " is not a valid absolute URI");
            }
            return null;
        }
        // The URL dereferencing classes throw all kinds of strange exceptions if given
        // ill-formed sequences of %hh escape characters. So we do a sanity check that the
        // escaping is well-formed according to UTF-8 rules
        try {
            EscapeURI.checkPercentEncoding(absoluteURI.toString());
        } catch (XPathException e) {
            if (debug) {
                throw e;
            }
            return null;
        }
        URL absoluteURL;
        try {
            absoluteURL = absoluteURI.toURL();
        } catch (MalformedURLException err) {
            if (debug) {
                throw new XPathException(err);
            }
            return null;
        }
        long lastMod;
        try {
            URLConnection connection = absoluteURL.openConnection();
            connection.setRequestProperty("Accept-Encoding","gzip");
            connection.connect();
            lastMod = connection.getLastModified();
        } catch (IOException e) {
            if (debug) {
                throw new XPathException(e);
            }
            return null;
        }

        if (lastMod == 0) {
View Full Code Here

                            }
                            setTransformerParameter(kid, transformer, source);
                        }
                        break;
                    default:
                        throw new XPathException(
                                "Parameters passed to saxon:transform() must be element, attribute, or document nodes");
                    }

                } else {
                    throw new XPathException("Parameters passed to saxon:transform() must be nodes");
                }
            }
            transformer.transform(source, builder);
            return (DocumentInfo)builder.getCurrentRoot();
        } catch (TransformerException e) {
View Full Code Here

                        Value val2 = ((NodeInfo)param).atomize();
                        dqc.setParameter(pool.getClarkName(kid.getNameCode()), val2);
                    }
                    break;
                default:
                    throw new XPathException(
                            "Parameters passed to saxon:query() must be element, attribute, or document nodes");
                }

            } else {
                throw new XPathException("Parameters passed to saxon:query() must be nodes");
            }
        }
        return query.iterator(dqc);
    }
View Full Code Here

        for (int i=0; i<components.length; i++) {
            ItemType it = components[i].getItemType(th);
            if (it instanceof NodeTest) {
                int possibleNodeKinds = ((NodeTest)it).getNodeKindMask();
                if (possibleNodeKinds == 1<<Type.ATTRIBUTE) {
                    XPathException de = new XPathException("Cannot create an attribute node whose parent is a document node");
                    de.setErrorCode(isXSLT ? "XTDE0420" : "XPTY0004");
                    de.setLocator(components[i]);
                    throw de;
                } else if (possibleNodeKinds == 1<<Type.NAMESPACE) {
                    XPathException de = new XPathException("Cannot create a namespace node whose parent is a document node");
                    de.setErrorCode(isXSLT ? "XTDE0420" : "XQTY0024");
                    de.setLocator(components[i]);
                    throw de;
                }
                if (possibleNodeKinds == 1<<Type.ELEMENT) {
                    elementCount++;
                    if (elementCount > 1 &&
                            (validation==Validation.STRICT || validation==Validation.LAX || type!=null)) {
                        XPathException de = new XPathException("A valid document must have only one child element");
                        if (isXSLT) {
                            de.setErrorCode("XTTE1550");
                        } else {
                            de.setErrorCode("XQDY0061");
                        }
                        de.setLocator(components[i]);
                        throw de;
                    }
                    if (validation==Validation.STRICT && components[i] instanceof FixedElement) {
                        SchemaDeclaration decl = env.getConfiguration().getElementDeclaration(
                                ((FixedElement)components[i]).getNameCode(null) & NamePool.FP_MASK);
View Full Code Here

TOP

Related Classes of org.pdf4j.saxon.trans.XPathException

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.