private Source readSource ( String xmlDocument , String features ) throws Exception { if ( xmlDocument . startsWith ( Constants . Inputs . HTTP_PREFIX_STRING ) || xmlDocument . startsWith ( Constants . Inputs . HTTPS_PREFIX_STRING ) ) { URL xmlUrl = new URL ( xmlDocument ) ; InputStream xmlStream = xmlUrl . openStream ( ) ; XmlUtils . parseXmlInputStream ( xmlStream , features ) ; return new StreamSource ( xmlStream ) ; } else { if ( new File ( xmlDocument ) . exists ( ) ) { XmlUtils . parseXmlFile ( xmlDocument , features ) ; return new StreamSource ( new FileInputStream ( xmlDocument ) ) ; } XmlUtils . parseXmlString ( xmlDocument , features ) ; return new StreamSource ( new StringReader ( xmlDocument ) ) ; } }
Reads the xml content from a file URL or string .