code: protected static String nameToId(String name) {
          try {
              return URLEncoder.encode(name, "UTF-8");
          } catch (UnsupportedEncodingException e) {
              // should not happen
              throw new RuntimeException("Unsupported encoding", e);
          }
      }
docs: utility methods to convert between a document name and a form that eXist accepts (ie URL-encoded)