protected void setBaseUri(String uri) throws URISyntaxException {
   if (useNewApi) {
     staticContextBuilder.withBaseUri(uri);
   } else {
     dynamicContext.set_base_uri(uri);
   }
 }
  public String extractXPathExpression(String xqFile, String inputFile, boolean unescape) {
    // get the xpath2 expr from xq file, first
    char[] cbuf = new char[2048]; //
    String content = null;
    String xpath2Expr = null;

    try {
      URL entryUrl = bundle.getEntry(xqFile);
      InputStream isxq = testResolve(entryUrl);
      if (useNewApi) {
        if (staticContextBuilder.getBaseUri() == null)
          try {
            staticContextBuilder.withBaseUri(entryUrl.toString());
          } catch (URISyntaxException e) {
            throw new RuntimeException(e); // drats
          }
      } else {
        if (dynamicContext.base_uri().getStringValue() == null)
          dynamicContext.set_base_uri(entryUrl.toString());
      }
      BufferedReader xqreader =
          new BufferedReader(new InputStreamReader(isxq, Charset.forName("UTF-8")));
      int nByte = xqreader.read(cbuf);
      assertTrue(xqFile, nByte < 2048);
      content = new String(cbuf).trim();
      //
      if (content.indexOf(INPUT_CONTEXT) != -1
          && content.indexOf(INPUT_CONTEXT1) == -1
          && content.indexOf(INPUT_CONTEXT2) == -1) {
        inputMap.put(INPUT_CONTEXT, inputFile);
      } else if (content.indexOf(INPUT_CONTEXT1) == -1) {
        inputMap.put(INPUT_CONTEXT1, inputFile);
      } else if (content.indexOf(INPUT_CONTEXT2) != -1) {
        inputMap.put(INPUT_CONTEXT2, inputFile);
      }
      //
      if (content.indexOf(DECLARE_NAMESPACE) != -1
          || content.indexOf(IMPORT_SCHEMA_NAMESPACE) != -1) {
        setupNamespace(content);
      }
      //
      assertTrue(content.lastIndexOf(S_COMMENT2) != -1); // assert to get
      xpath2Expr = content.substring(content.lastIndexOf(S_COMMENT2) + 2).trim();
      xqreader.close();
      isxq.close();
    } catch (IOException e) {
      throw new RuntimeException("Can't extract XPath expression from XQuery file : " + xqFile, e);
    }
    if (unescape && xpath2Expr.contains("&")) {
      return resolveCharacterReferences(xpath2Expr);
    } else {
      return xpath2Expr;
    }
  }