Examples of XQuery


Examples of nux.xom.xquery.XQuery

        if ("Inspect".equals(compare)) inspect = true;
      }
       
      Nodes results = null;
      try { // here's where the query is actually executed
        XQuery xquery = new XQuery(squery, testSourcesDir.toURI());
//        XQuery xquery = new XQuery(squery, query.toURI());
//        XQuery xquery = XQueryPool.GLOBAL_POOL.getXQuery(squery, query.toURI());
        results = xquery.execute(null, null, vars).toNodes();
      } catch (Throwable t) {
        if (!inspect && expectedErrors.size() == 0) {
          System.out.println(XOMUtil.toPrettyXML(testCase));
          throw t;
        }
View Full Code Here

Examples of nux.xom.xquery.XQuery

        }
        for (int i=0; i < queries.size(); i++) {
          long start = System.currentTimeMillis();
          long serializationTime = 0;
          Object query = queries.get(i);
          XQuery xquery;
          if (query instanceof String) {
            xquery = queryPool.getXQuery((String)query, baseURI);
          } else if (query instanceof File) {
            xquery = queryPool.getXQuery((File)query, baseURI);
          } else {
            xquery = null; // disable XQuery for benchmarking
          }
         
          if (isBench) {
            System.out.println("query = " +query);
          }
          if (explain && run == 0 && xquery != null) {
            System.out.println("explain = \n" + xquery.explain());
          }
         
          XQuery morpher;
          if (update instanceof String) {
            morpher = queryPool.getXQuery((String)update, null);
          } else if (update instanceof File) {
            morpher = queryPool.getXQuery((File)update, null);
          } else {
View Full Code Here

Examples of nux.xom.xquery.XQuery

   *             if the query has a syntax error, or if it references
   *             namespaces, variables, or functions that have not been
   *             declared, or contains other static errors such as type mismatches.
   */
  public XQuery createXQuery(String query, URI baseURI) throws XQueryException {
    return new XQuery(query, baseURI, null, resolver);
  }
View Full Code Here

Examples of nux.xom.xquery.XQuery

//            actualRuns = Math.min(runs, 10); // this one would take too long
            continue; // ignore
          }
          System.out.print("query = " + selects[i] + "  ");
          if (actualRuns == 1) System.out.println(
            "\nexplain = \n" + new XQuery(selects[i], null).explain());
          XQuery xquery = new XQuery(selects[i], null);
                 
          // now execute the query N times and measure execution time
          long start = System.currentTimeMillis();
          IS_BENCHMARK = true;
          Nodes results = run(contexts[i], selects[i], actualRuns, mode, types[i], xquery);
View Full Code Here

Examples of nux.xom.xquery.XQuery

          break;
        case 0 : // Nux with query cache
          results = XQueryUtil.xquery(contextNode, query);
          break;
        case 1 : // Nux without query cache
          results = new XQuery(query, null).execute(contextNode).toNodes();
          break;
        case 2 : // xom-1.1
          try {
            results = contextNode.query(query);
          } catch (XPathException e) {
View Full Code Here

Examples of nux.xom.xquery.XQuery

  public XQuery getXQuery(File query) throws XQueryException, IOException {
    if (query == null)
      throw new IllegalArgumentException("query must not be null");

    Object key = query;
    XQuery xquery = (XQuery) entries.get(key);
    if (xquery == null) {
      xquery = factory.createXQuery(query);
      entries.put(key, xquery);
    }
    return xquery;
View Full Code Here

Examples of nux.xom.xquery.XQuery

  public XQuery getXQuery(File query, URI baseURI) throws XQueryException, IOException {
    if (query == null)
      throw new IllegalArgumentException("query must not be null");

    Object key = Pool.createHashKeys(new Object[] {query, baseURI, null, null});
    XQuery xquery = (XQuery) entries.get(key);
    if (xquery == null) {
      xquery = factory.createXQuery(query, baseURI);
      entries.put(key, xquery);
    }
    return xquery;
View Full Code Here

Examples of nux.xom.xquery.XQuery

    if (baseURI == null)
      key = query; // fast path
    else
      key = Pool.createHashKeys(new Object[] {query, baseURI});
   
    XQuery xquery = (XQuery) entries.get(key);
    if (xquery == null) {
      xquery = factory.createXQuery(query, baseURI);
      entries.put(key, xquery);
    }
    return xquery;
View Full Code Here

Examples of nux.xom.xquery.XQuery

      throw new IllegalArgumentException("resolver must not be null");
    if (resourceName == null)
      throw new IllegalArgumentException("resourceName must not be null");
   
    Object key = Pool.createHashKeys(new Object[] {resourceName, baseURI, null});
    XQuery xquery = (XQuery) entries.get(key);
    if (xquery == null) {
      InputStream query = resolver.getResourceAsStream(resourceName);
      if (query == null) {
        throw new MissingResourceException(
          "Resource '" + resourceName + "' could not be found by resolver: " +
View Full Code Here

Examples of nux.xom.xquery.XQuery

  public static void main(String[] args) throws Exception {   
    String query = args[0];
    Document doc = null;
    if (args.length > 1) doc = new Builder().build(new File(args[1]));
   
    XQuery xquery;
    if (query.startsWith("{") && query.endsWith("}")) {
      // query is given inline between curly brackets, ala Saxon command line tool
      String strippedQuery = query.substring(1, query.length()-1);
      xquery = XQueryPool.GLOBAL_POOL.getXQuery(strippedQuery, null);
    } else {
      // otherwise it refers to a file containing the query string
      xquery = XQueryPool.GLOBAL_POOL.getXQuery(new File(query));
    }
   
    Nodes results = xquery.execute(doc).toNodes();
   
    for (int j=0; j < results.size(); j++) {
      boolean prettyPrint = true;
      if (prettyPrint)
        System.out.println(XOMUtil.toPrettyXML(results.get(j)));
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.