code: public void save(XMLStreamWriter stream) throws XMLStreamException {
          stream.writeStartDocument("UTF-8", "1.0");
          
          saveInternal(stream);
          
          stream.writeEndDocument();
      }
docs: Save the tree into the given XML stream writer.
  @param stream the stream writer
  @throws XMLStreamException if an error occurs