code: public String extract(Object target) {
          if (target == null) {
              return null;
          }
  
          Document sourceDoc = (Document) target;
          Element sourceElement = sourceDoc.getDocumentElement();
          String nsUri = namespace == null
                         ? sourceElement.getNamespaceURI()
                         : namespace;
  
          if (sourceElement.hasAttributeNS(nsUri, nodeName)) {
              return sourceElement.getAttributeNS(nsUri, nodeName);
          }
          else {
              NodeList candidates = sourceElement.getElementsByTagNameNS(nsUri,
                                                                         nodeName);
              if (candidates.getLength() > 0) {
                  return candidates.item(0).getTextContent();
              }
          }
          return null;
      }
docs: {@inheritDoc}