code: public static String evaluateXPointer(String xpointer, InputStream is) {
          String results = "";
          // Parse the XPointer into usable namespaces and XPath expressions
          int xmlnsStart = xpointer.indexOf("xmlns(") + "xmlns(".length();
          int xmlnsEnd = xpointer.indexOf(")", xmlnsStart);
          int xpathStart = xpointer.indexOf("xpointer(") + "xpointer(".length();
          int xpathEnd = xpointer.indexOf(")", xpathStart);
          String xmlnsStr = xpointer.substring(xmlnsStart, xmlnsEnd);
          String xpathStr = xpointer.substring(xpathStart, xpathEnd);
          // System.out.println("xmlnsStr: "+xmlnsStr+" xpathStr: "+xpathStr);
          try {
              XPath xpath = XPathFactory.newInstance().newXPath();
              String[] namespaces = xmlnsStr.split(",");
              // Add namespaces to XPath element
              MyNamespaceContext context = new MyNamespaceContext();
              for (int i = 0; i < namespaces.length; i++) {
                  String[] xmlnsParts = namespaces[i].split("=");
                  context.setNamespace(xmlnsParts[0], xmlnsParts[1]);
                  xpath.setNamespaceContext(context);
              }
              InputSource src = new InputSource(is);
              results = (String) xpath.evaluate(xpathStr, src);
              // System.out.println("results: "+results);
          } catch (Exception e) {
              jlogger.log(Level.SEVERE,
                      "Error in evaluating XPointer.  " + e.getMessage(), e);
  
              System.out.println("Error in evaluating XPointer.  "
                      + e.getMessage());
          }
          return results;
      }
docs: Converts an XPointer to XPath and evaulates the result (JAXP)