code: public String buildServiceDocument() throws ODataRenderException {
          LOG.info("Building service(root) document");
          try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(BUFFER_SIZE)) {
              XMLStreamWriter writer = startServiceDocument(outputStream);
  
              writeEntitySets(writer);
              writeSingleton(writer);
  
              endServiceDocument(writer);
              LOG.info("Successfully built service document");
              return outputStream.toString();
          } catch (XMLStreamException | IOException e) {
              String msg = "Something went wrong when writing service document.";
              LOG.error(msg, e);
              throw new ODataRenderException(msg, e);
          }
      }
docs: This is main method which generates service document.
  
  @return generated service (root collection) document
  @throws ODataRenderException in case of errors