Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

New serializeDocument(Elem, OutputStream) to be used with OutputStreams. #56

Merged
merged 1 commit into from Sep 25, 2011

Commits on Sep 25, 2011

  1. New serializeDocument(Elem, OutputStream) to be used with OutputStreams.

    Uses the character encoding of the XMLSerializer.
    
    Motivation: when XMLSerializer is created, an encoding is specified. This
    encoding is used when writing the XML declaration. Using the
    serializeDocument(Elem, Writer) can lead to a stupid-user-error where the
    encoding given and the encoding of the Writer (e.g. OutputStreamWriter) are not
    the same.
    
    For example, on a platform, whose default encoding is ISO-8859-1, the following
    innocent looking code would lead to a disaster:
    
    XMLSerializer("UTF-8", true).serializeDocument(root, new OutputStreamWriter(myOutputStream))
    
    In the above, the declaration written by XMLSerializer would state "UTF-8", but
    the data written by the Writer would be in ISO-8859-1.
    Heikki Vesalainen committed Sep 25, 2011
    Copy the full SHA
    c5a2392 View commit details
    Browse the repository at this point in the history