Examples of XPathEvaluator


Examples of com.envoisolutions.sxc.xpath.XPathEvaluator

        };
   
    XPathBuilder builder = new XPathBuilder();
        builder.listen(target, eventHandler);

        XPathEvaluator evaluator = builder.compile();

        for(int i = 0; i < NUM_WARMUPS; i++) {
            evaluator.evaluate(getMessageReader(message));
        }

        long start = System.currentTimeMillis();
        for(int i = 0; i < NUM_ITERATIONS; i++) {
            evaluator.evaluate(getMessageReader(message));
        }
        System.out.println("Took: " + (System.currentTimeMillis() - start));
        assertTrue(match[0]);
        //System.out.println(invCount[0]);
  }
View Full Code Here

Examples of dk.brics.xpath.evaluator.XPathEvaluator

    this.dummy_root = dummy_root;
    this.dummy_root_content = dummy_root_content;
    this.stm_nodes = stm_nodes;
    this.empty_xpath = empty_xpath;
    this.check_fails = check_fails;
    evaluator = new XPathEvaluator();
    evaluation_context = new EvaluationContext();
    evaluation_context.setDefaultNamespace("");
    evaluation_context.addNamespaces(namespaces);
    evaluator.setEvaluationContext(evaluation_context);
   
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

    public static String xpathValue(Object doc, String xpath) throws XPathException, TeiidProcessingException {
      Source s = null;
        try {
          s = convertToSource(doc);
            XPathEvaluator eval = new XPathEvaluator();
            // Wrap the string() function to force a string return            
            XPathExpression expr = eval.createExpression(xpath);
            Object o = expr.evaluateSingle(s);
           
            if(o == null) {
                return null;
            }
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

    public static void validateXpath(String xpath) throws XPathException {
        if(xpath == null) {
            return;
        }
       
        XPathEvaluator eval = new XPathEvaluator();
        eval.createExpression(xpath);
    }
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

  private void processColumns(List<XMLTable.XMLColumn> columns, IndependentContext ic)
      throws QueryResolverException {
    if (columns == null) {
      return;
    }
        XPathEvaluator eval = new XPathEvaluator(config);
      eval.setStaticContext(ic);
    for (XMLColumn xmlColumn : columns) {
          if (xmlColumn.isOrdinal()) {
            continue;
          }
          String path = xmlColumn.getPath();
          if (path == null) {
            path = xmlColumn.getName();
          }
          path = path.trim();
          if (path.startsWith("/")) { //$NON-NLS-1$
            if (path.startsWith("//")) { //$NON-NLS-1$
              path = '.' + path;
            } else {
              path = path.substring(1);
            }
          }
        XPathExpression exp;
      try {
        exp = eval.createExpression(path);
      } catch (XPathException e) {
        throw new QueryResolverException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.invalid_path", xmlColumn.getName(), xmlColumn.getPath())); //$NON-NLS-1$
     
        xmlColumn.setPathExpression(exp);
    }
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

    public List selectNodes(Object node)
    {
        try
        {
            Node contextNode = (Node)node;
            XPathEvaluator xpe = new XPathEvaluator();
            Configuration config = new Configuration();
            config.setDOMLevel(2);
            config.setTreeModel(net.sf.saxon.event.Builder.STANDARD_TREE);
            IndependentContext sc = new IndependentContext(config);
            // Declare ns bindings
            if (defaultNS != null)
                sc.setDefaultElementNamespace(defaultNS);

            for (int i = 0; i < namespaceMap.length; i++)
            {
                Map.Entry entry = (Map.Entry) namespaceMap[i];
                sc.declareNamespace((String) entry.getKey(),
                        (String) entry.getValue());
            }
            xpe.setStaticContext(sc);
            XPathVariable thisVar = xpe.declareVariable("", contextVar);
            XPathExpression xpath = xpe.createExpression(path);
            NodeInfo contextItem =
                //config.buildDocument(new DOMSource(contextNode));
                config.unravel(new DOMSource(contextNode));
            XPathDynamicContext dc = xpath.createDynamicContext(null);
            dc.setContextItem(contextItem);
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

                                builder.setPipelineConfiguration(saConfig.makePipelineConfiguration());
                                ExpressionPresenter presenter = new ExpressionPresenter(saConfig, builder);
                                xqe.explain(presenter);
                                presenter.close();
                                NodeInfo expressionTree = builder.getCurrentRoot();
                                XPathEvaluator xpe = new XPathEvaluator(saConfig);
                                XPathExpression exp = xpe.createExpression(assertion);
                                try {
                                    Boolean bv = (Boolean)exp.evaluateSingle(expressionTree);
                                    if (bv == null || !bv.booleanValue()) {
                                        log.println("** Optimization assertion failed");
                                        optimizationOK = false;
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

        config.setOptimizerTracing(false);
        if (xml != null) {
            source = buildSource(xml, validationMode);
            if (initialContextPath != null) {
                DocumentInfo doc = config.buildDocument(source);
                XPathEvaluator xpe = new XPathEvaluator(config);
                XPathExpression expr = xpe.createExpression(initialContextPath);
                source = (NodeInfo)expr.evaluateSingle(doc);
            }
        }
        Templates sheet;
        try {
            Source styleSource;
            if (useAssociated) {
                styleSource = f.getAssociatedStylesheet(source, null, null, null);
            } else {
                styleSource = new StreamSource(new File(xsl));
            }
            sheet = f.newTemplates(styleSource);
        } catch (TransformerConfigurationException e) {
            XPathException e2 = XPathException.makeXPathException(e);
            e2.setIsStaticError(true);
            throw e2;
        }

        if (assertion != null) {
            TinyBuilder builder = new TinyBuilder();
            builder.setPipelineConfiguration(config.makePipelineConfiguration());
            ExpressionPresenter presenter = new ExpressionPresenter(config, builder);
            ((PreparedStylesheet)sheet).explain(presenter);
            presenter.close();
            NodeInfo expressionTree = builder.getCurrentRoot();
            XPathEvaluator xpe = new XPathEvaluator(config);
            XPathExpression exp = xpe.createExpression(assertion);
            Boolean bv = (Boolean)exp.evaluateSingle(expressionTree);
            if (!bv.booleanValue()) {
                System.err.println("** Optimization assertion failed");
                presenter = new ExpressionPresenter(config);
                ((PreparedStylesheet)sheet).explain(presenter);
View Full Code Here

Examples of net.sf.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 = config.newStaticQueryContext();
            sqc.setBaseURI(new File(args[1]).toURI().toString());
            XQueryExpression xqe = sqc.compileQuery(new FileReader(args[1]));
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

        if (argument.length > 2) {
            Value errorObject = ((Value)SequenceExtent.makeSequenceExtent(argument[2].iterate(context))).reduce();
            if (errorObject instanceof SingletonItem) {
                Item root = ((SingletonItem)errorObject).getItem();
                if ((root instanceof NodeInfo) && ((NodeInfo)root).getNodeKind() == Type.DOCUMENT) {
                    XPathEvaluator xpath = new XPathEvaluator();
                    XPathExpression exp = xpath.createExpression("/error/@module");
                    NodeInfo moduleAtt = (NodeInfo)exp.evaluateSingle((NodeInfo)root);
                    String module = (moduleAtt == null ? null : moduleAtt.getStringValue());
                    exp = xpath.createExpression("/error/@line");
                    NodeInfo lineAtt = (NodeInfo)exp.evaluateSingle((NodeInfo)root);
                    int line = (lineAtt == null ? -1 : Integer.parseInt(lineAtt.getStringValue()));
                    exp = xpath.createExpression("/error/@column");
                    NodeInfo columnAtt = (NodeInfo)exp.evaluateSingle((NodeInfo)root);
                    int column = (columnAtt == null ? -1 : Integer.parseInt(columnAtt.getStringValue()));
                    ExpressionLocation locator = new ExpressionLocation();
                    locator.setSystemId(module);
                    locator.setLineNumber(line);
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.