Code example for StreamSource

Methods: getInputStream, getPublicId, getReader, getSystemId

0
     * Creates a proper {@link XMLInputSource} from a {@link StreamSource}. 
     * 
     * @return always return non-null valid object. 
     */ 
    public static final XMLInputSource toXMLInputSource( StreamSource in ) {
        if( in.getReader()!=null )
            return new XMLInputSource( 
            in.getPublicId(), in.getSystemId(), in.getSystemId(),
            in.getReader(), null );
        if( in.getInputStream()!=null )
            return new XMLInputSource( 
            in.getPublicId(), in.getSystemId(), in.getSystemId(),
            in.getInputStream(), null );
         
        return new XMLInputSource( 
        in.getPublicId(), in.getSystemId(), in.getSystemId() );
    } 
     
    /** 
     * Reconstructs {@link SAXException} from XNIException. 
     */