Esempio n. 1
0
 /**
  * Parses a module.
  *
  * @param io input reference
  * @return query parser
  * @throws QueryException query exception
  */
 final QueryParser parseQuery(final IO io) throws QueryException {
   try (final QueryContext qctx = new QueryContext(qc)) {
     final String input = string(io.read());
     // parse query
     final QueryParser qp = new QueryParser(input, io.path(), qctx, null);
     module = QueryProcessor.isLibrary(input) ? qp.parseLibrary(true) : qp.parseMain();
     return qp;
   } catch (final IOException | QueryException ex) {
     throw IOERR_X.get(info, ex);
   }
 }
Esempio n. 2
0
 /**
  * Parses and returns an xquery expression.
  *
  * @param cmd referring command; if specified, the result must not be empty
  * @return path
  * @throws QueryException query exception
  */
 private String xquery(final Cmd cmd) throws QueryException {
   consumeWS();
   final StringBuilder sb = new StringBuilder();
   if (!eoc()) {
     final QueryContext qc = new QueryContext(ctx);
     try {
       final QueryParser p = new QueryParser(parser.input, null, qc, null);
       p.pos = parser.pos;
       p.parseMain();
       sb.append(parser.input.substring(parser.pos, p.pos));
       parser.pos = p.pos;
     } finally {
       qc.close();
     }
   }
   return finish(sb, cmd);
 }