code: public static InputSource sourceToInputSource(Source source) {
  
          if (source instanceof SAXSource) {
              return ((SAXSource) source).getInputSource();
          } else if (source instanceof StreamSource) {
              StreamSource ss      = (StreamSource) source;
              InputSource  isource = new InputSource(ss.getSystemId());
  
              isource.setByteStream(ss.getInputStream());
              isource.setCharacterStream(ss.getReader());
              isource.setPublicId(ss.getPublicId());
  
              return isource;
          } else {
              return null;
          }
      }
docs: Attempt to obtain a SAX InputSource object from a Source
  object.
  
  @param source Must be a non-null Source reference.
  
  @return An InputSource, or null if Source can not be converted.