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
 /**
  * Test query for stripping existing namespaces.
  *
  * @throws Exception exception
  */
 @Test
 public void stripNS() throws Exception {
   final IO io = IO.get("<a xmlns:a='a'><b><c/><c/><c/></b></a>");
   try (final QueryProcessor qp =
       new QueryProcessor("/*:a/*:b", context).context(new DBNode(io))) {
     final ANode sub = (ANode) qp.iter().next();
     DataBuilder.stripNS(sub, token("a"), context);
   }
 }