protected Object buildXPath(final String query, final boolean moreNodes) {
    try {
      XPathExecutable x = xPathCompiler.compile(query);

      XPathSelector selector = x.load();
      selector.setContextItem(this.contextItem);
      XdmValue value = selector.evaluate();
      if (moreNodes) {
        String[] list = new String[value.size()];
        int i = 0;
        for (XdmItem xdmItem : value) {         
          list[i] = xdmItem.toString();
          ++i;
        }
        // Replace attribute chars
        return MetadataParserHelper.removeAttributeChars(list);
      }      
     
      ValueRepresentation rep = value.getUnderlyingValue();
      // Replace attribute chars
      return MetadataParserHelper.removeAttributeChars(rep.getStringValue());   
    } catch (SaxonApiException | XPathException e) {
      e.printStackTrace();
      return null;
    }
  }