Examples of XPathEvaluator


Examples of org.pdf4j.saxon.sxpath.XPathEvaluator

    public static void main(String[] args) throws Exception {
        Configuration config = new Configuration();
        Expression exp;
        if (args[0].equals("xpath")) {
            XPathEvaluator xpath = new XPathEvaluator(config);
            XPathExpression xpexp = xpath.createExpression(args[1]);
            exp = xpexp.getInternalExpression();
        } else if (args[0].equals("xquery")) {
            StaticQueryContext sqc = new StaticQueryContext(config);
            sqc.setBaseURI(new File(args[1]).toURI().toString());
            XQueryExpression xqe = sqc.compileQuery(new FileReader(args[1]));
View Full Code Here

Examples of org.pdf4j.saxon.sxpath.XPathEvaluator

     * @throws SaxonApiException if any static error is detected while analyzing the expression
     */

    public XPathExecutable compile(String source) throws SaxonApiException {
        try {
            XPathEvaluator eval = new XPathEvaluator(processor.getUnderlyingConfiguration());
            eval.setStaticContext(env);
            XPathExpression cexp = eval.createExpression(source);
            return new XPathExecutable(cexp, processor, env, declaredVariables);
        } catch (XPathException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

Examples of org.pdf4j.saxon.sxpath.XPathEvaluator

     * @since 9.1
     */

    public XPathExecutable compilePattern(String source) throws SaxonApiException {
        try {
            XPathEvaluator eval = new XPathEvaluator(processor.getUnderlyingConfiguration());
            eval.setStaticContext(env);
            XPathExpression cexp = eval.createPattern(source);
            return new XPathExecutable(cexp, processor, env, declaredVariables);
        } catch (XPathException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

Examples of org.pdf4j.saxon.sxpath.XPathEvaluator

        if (argument.length > 2) {
            Value errorObject = ((Value)SequenceExtent.makeSequenceExtent(argument[2].iterate(context))).reduce();
            if (errorObject instanceof SingletonNode) {
                NodeInfo root = ((SingletonNode)errorObject).getNode();
                if (root.getNodeKind() == Type.DOCUMENT) {
                    XPathEvaluator xpath = new XPathEvaluator();
                    XPathExpression exp = xpath.createExpression("/error/@module");
                    NodeInfo moduleAtt = (NodeInfo)exp.evaluateSingle(root);
                    String module = (moduleAtt == null ? null : moduleAtt.getStringValue());
                    exp = xpath.createExpression("/error/@line");
                    NodeInfo lineAtt = (NodeInfo)exp.evaluateSingle(root);
                    int line = (lineAtt == null ? -1 : Integer.parseInt(lineAtt.getStringValue()));
                    exp = xpath.createExpression("/error/@column");
                    NodeInfo columnAtt = (NodeInfo)exp.evaluateSingle(root);
                    int column = (columnAtt == null ? -1 : Integer.parseInt(columnAtt.getStringValue()));
                    ExpressionLocation locator = new ExpressionLocation();
                    locator.setSystemId(module);
                    locator.setLineNumber(line);
View Full Code Here

Examples of org.pdf4j.saxon.xpath.XPathEvaluator

    public static void main (String[] args) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder db = factory.newDocumentBuilder();
        Document doc = db.newDocument();
        XPathEvaluator xpe = new XPathEvaluator();
        String exp = "ext:sortArrayToNodeList(('fred', 'jane', 'anne', 'sue'))";
        xpe.setNamespaceContext(new NamespaceContext() {
            public String getNamespaceURI(String prefix) {
                return (prefix.equals("ext") ? "java:org.orbeon.saxon.dom.DOMObjectModel" : null);
            }
            public String getPrefix(String namespaceURI) {
                return null;
            }
            public Iterator getPrefixes(String namespaceURI) {
                return null;
            }
        });
        NodeList isList = (NodeList)xpe.evaluate(exp, doc, XPathConstants.NODESET);
        System.err.println("length " + isList.getLength());
    }
View Full Code Here

Examples of org.w3c.dom.xpath.XPathEvaluator

             * provide one for us, which means prefixes will not be resolved
             * in the query (Xalan will just throw an error if a prefix
             * is used).  In the future we may want to revisit this
             * to make it easier for users to query based on namespaces.
             */
            XPathEvaluator eval = (XPathEvaluator)
                dBuilder.getDOMImplementation().getFeature("+XPath", "3.0");
            query = eval.createExpression(queryExpr, null);

            this.queryExpr = queryExpr;
            this.opName = opName;
            this.recompileQuery = false;

View Full Code Here

Examples of org.w3c.dom.xpath.XPathEvaluator

      // Use the DOM L3 XPath API to apply the xpath expression to the doc.
      System.out.println("Querying DOM using "+xpath);
     
      // Create an XPath evaluator and pass in the document.
      XPathEvaluator evaluator = new XPathEvaluatorImpl(doc);
      XPathNSResolver resolver = evaluator.createNSResolver(doc);
     
      // Evaluate the xpath expression
      XPathResult result = (XPathResult)evaluator.evaluate(xpath, doc, resolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
     

      // Serialize the found nodes to System.out.
      System.out.println("<output>");
                 
View Full Code Here

Examples of org.w3c.dom.xpath.XPathEvaluator

      // Use the DOM L3 XPath API to apply the xpath expression to the doc.
      System.out.println("Querying DOM using "+xpath);
     
      // Create an XPath evaluator and pass in the document.
      XPathEvaluator evaluator = new XPathEvaluatorImpl(doc);
      XPathNSResolver resolver = evaluator.createNSResolver(doc);
     
      // Evaluate the xpath expression
      XPathResult result = (XPathResult)evaluator.evaluate(xpath, doc, resolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
     

      // Serialize the found nodes to System.out.
      System.out.println("<output>");
                 
View Full Code Here

Examples of org.w3c.dom.xpath.XPathEvaluator

      // Use the DOM L3 XPath API to apply the xpath expression to the doc.
      System.out.println("Querying DOM using "+xpath);
     
      // Create an XPath evaluator and pass in the document.
      XPathEvaluator evaluator = new XPathEvaluatorImpl(doc);
      XPathNSResolver resolver = evaluator.createNSResolver(doc);
     
      // Evaluate the xpath expression
      XPathResult result = (XPathResult)evaluator.evaluate(xpath, doc, resolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
     

      // Serialize the found nodes to System.out.
      System.out.println("<output>");
                 
View Full Code Here

Examples of org.w3c.dom.xpath.XPathEvaluator

             * provide one for us, which means prefixes will not be resolved
             * in the query (Xalan will just throw an error if a prefix
             * is used).  In the future we may want to revisit this
             * to make it easier for users to query based on namespaces.
             */
            XPathEvaluator eval = (XPathEvaluator)
                dBuilder.getDOMImplementation().getFeature("+XPath", "3.0");
            query = eval.createExpression(queryExpr, null);

            this.queryExpr = queryExpr;
            this.opName = opName;
            this.recompileQuery = false;

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.