fix #837. Stop parsing if a reference entity is encountered in the prolog.
make the xml sax parser a daemon and terminate it in the object's finalize method.
fix #839. copy the user data when moving a node to another document.
fix #838. catch NPE which result from parsing '<? ?>'.
remove some unused imports.
require 'stringio' for the JRuby implementation.

Unfortunately this error doesn't surface in the tests because someone
is requiring it.
fix #834. properly handle self closing tags in xhtml docs.
fix #835. replace the fix for #719 from 0d8c3f2 with a simpler fix (more info below).

The fix for #719 made ReferenceEntity nodes look like text nodes. This
caused normalization of the document (i.e. concatenating adjacent
nodes) to combine the reference entity node with any adjacent text
nodes and create a new text node. When converting the document to
a string it was impossible to know if the text came from a reference
entity or text node, or both, which caused entities to be printed
without the delimiters '&' and ';'.