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 ; } }
Attempt to obtain a SAX InputSource object from a Source object .