def stream=( source )
if source.kind_of? String
@source = Source.new(source)
elsif source.kind_of? IO
@source = IOSource.new(source)
elsif source.kind_of? Source
@source = source
elsif defined? StringIO and source.kind_of? StringIO
@source = IOSource.new(source)
elsif defined? OpenSSL and source.kind_of? OpenSSL::SSL::SSLSocket
@source = IOSource.new(source)
else
raise "#{source.class} is not a valid input stream. It must be \n"+
"either a String, IO, StringIO or Source."
end
@closed = nil
@document_status = nil
@tags = []
@stack = []
@entities = []
end