code: public String execute(final String pointerStr, final Source source)
      {
          try
          {
              final StringWriter stringWriter = new StringWriter();
              final Serializer serializer = processor.newSerializer(stringWriter);
              serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
              executeToDestination(pointerStr, source, serializer);
              return stringWriter.toString();
          }
          catch (final XPointerException e)
          {
              final String message = e.getLocalizedMessage();
              if (xPointerErrorHandler != null)
              {
                  xPointerErrorHandler.reportError(message);
              }
              else
              {
                  LOG.error(message, e);
              }
          }
          return "";
      }
docs: Execute xpointer expression on a xml source returning a xml string
  
  @param pointerStr xpointer expression
  @param source xml source
  @return serialized xml result or an empty string (not null)