Refactored: move the preferred toInputStream method first
Renamed XmlDocumentGenerator to XmlGenerator