code: public static XMLStreamWriter startDocument(ByteArrayOutputStream outputStream,
                                                  String prefix, String documentRootName, String nameSpaceURI)
              throws XMLStreamException {
          XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(outputStream, UTF_8.name());
          if (isNullOrEmpty(prefix)) {
              writer.writeStartElement(documentRootName);
              writer.setDefaultNamespace(nameSpaceURI);
              writer.writeDefaultNamespace(nameSpaceURI);
          } else {
              writer.writeStartElement(prefix, documentRootName, nameSpaceURI);
              writer.writeNamespace(prefix, nameSpaceURI);
          }
          return writer;
      }
docs: Creates document root with given name.
  
  @param outputStream     stream to write to
  @param prefix           if given prefix is not null then root element will be prefixed
  followed by ":" and documentRootName
  @param documentRootName name of the document root element. This should not be null. Null check not done
  @param nameSpaceURI     name space of the element. This should not be null. Null check not done
  @return created XMLStreamWriter will be returned
  @throws XMLStreamException If unable to open stream