def prettify(input, output, strict=True, indentString='  ', color=False,
             encoding=DEFAULT_ENCODING):
  '''
  Converts the input data stream `input` (which must be a file input
  like object) to `output` (which must be a file output like object)
  by parsing the stream as XML and outputting "prettified"
  XML. Prettification involves the following aspects:

  * Collapsing ignorable whitespace.
  * Indenting nodes by `indentString`.
  * Colorizing the output to more easily identify elements if
    `color` is True or a color specification (see below).
  * Normalizing attribute rendering.
    TODO: that should include canonical ordering of attributes...

  :Parameters:

  strict : bool, default: true, optional
    If the input stream cannot be parsed by python's xml.dom.minidom,
    then if `strict` is True (the default), an exception is raised. If
    `strict` is False, then the input data is streamed to `output`
    as-is.

  indentString : str, default: '  ', optional
    The indentation to add to the output stream when entering into a
    sub-element. Note that this indentation is only added if it will
    remain "ignorable whitespace" according to the XML specification.

  color : bool, default: false, optional
    Whether or not to add *terminfo* terminal colorization sequences
    to add XML syntax highlighting, including element names, attribute
    names, and other XML syntax characters.

  encoding : str, default: 'UTF-8', optional
    Specify the encoding to use when rendering the XML. By default, it
    uses ``"UTF-8"``.

  :Returns:

  True
    the input stream was successfully converted.

  False
    a parsing error occurred and `strict` was False.

  Exception
    other errors (such as IOErrors) occurred.
  '''
  data = input.read()
  try:
    dom = xml.dom.minidom.parseString(data)
  except Exception:
    if strict:
      raise
    output.write(data)
    return False
  removeIgnorableWhitespace(dom)
  indentXml(dom, dom.documentElement, indentString)
  if color:
    return colorizeXml(dom, output, encoding=encoding, colorspec=color)
  xout = dom.toxml(encoding=encoding) + b'\n'
  output.write(re.sub(b'^(<\\?xml[^>]+?>)', b'\\1\n', xout))
  return True
Converts the input data stream `input` (which must be a file input
  like object) to `output` (which must be a file output like object)
  by parsing the stream as XML and outputting "prettified"
  XML. Prettification involves the following aspects:

  * Collapsing ignorable whitespace.
  * Indenting nodes by `indentString`.
  * Colorizing the output to more easily identify elements if
    `color` is True or a color specification (see below).
  * Normalizing attribute rendering.
    TODO: that should include canonical ordering of attributes...

  :Parameters:

  strict : bool, default: true, optional
    If the input stream cannot be parsed by python's xml.dom.minidom,
    then if `strict` is True (the default), an exception is raised. If
    `strict` is False, then the input data is streamed to `output`
    as-is.

  indentString : str, default: '  ', optional
    The indentation to add to the output stream when entering into a
    sub-element. Note that this indentation is only added if it will
    remain "ignorable whitespace" according to the XML specification.

  color : bool, default: false, optional
    Whether or not to add *terminfo* terminal colorization sequences
    to add XML syntax highlighting, including element names, attribute
    names, and other XML syntax characters.

  encoding : str, default: 'UTF-8', optional
    Specify the encoding to use when rendering the XML. By default, it
    uses ``"UTF-8"``.

  :Returns:

  True
    the input stream was successfully converted.

  False
    a parsing error occurred and `strict` was False.

  Exception
    other errors (such as IOErrors) occurred.