code: public StreamSource getTransformerStream(String strDocument)
      {
          StreamSource source = null;
          if (strDocument.indexOf(':') == -1)
          {   // See if it is a file name
              try {   // First try it as a filename
                  FileReader reader = new FileReader(strDocument);
                  if (reader != null)
                      source = new StreamSource(reader);
              } catch (IOException ex)    {
                  source = null;
              }                    
          }
          if (source == null)
          {
              try {
                  URL url = new URL(strDocument);
                  InputStream is = url.openStream();
                  source = new StreamSource(is);
              } catch (IOException ex)    {
                  source = null;
              }
          }
          return source;
      }
docs: GetTransformerStream Method.