code: public void writeMetadataDocument() throws ODataRenderException {
  
          try {
              xmlWriter.writeStartElement(EDMX_NS, EDMX);
              xmlWriter.writeNamespace(EDMX_PREFIX, EDMX_NS);
              xmlWriter.writeAttribute(VERSION, ODATA_VERSION);
              xmlWriter.writeStartElement(EDMX_NS, EDMX_DATA_SERVICES);
  
              boolean entityContinerWritten = false;
              // Loop over all the schemas present in the Entity Data Model
              for (Schema schema : entityDataModel.getSchemas()) {
                  xmlWriter.writeStartElement(SCHEMA);
                  xmlWriter.writeDefaultNamespace(EDM_NS);
                  xmlWriter.writeAttribute(NAMESPACE, schema.getNamespace());
                  for (Type type : schema.getTypes()) {
                      switch (type.getMetaType()) {
                          case ENTITY:
                              entityTypeWriter.write((EntityType) type);
                              break;
                          case COMPLEX:
                              complexTypeWriter.write((ComplexType) type);
                              break;
                          case ENUM:
                              enumTypeWriter.write((EnumType) type);
                              break;
                          default:
                              LOG.error("Unexpected type: {}", type.getFullyQualifiedName());
                              throw new ODataRenderException("Unexpected type: " + type.getFullyQualifiedName());
                      }
                  }
                  if (!entityContinerWritten) {
                      writeEntityContainer(entityDataModel.getEntityContainer());
                      entityContinerWritten = true;
                  }
  
                  // End of <Schema> element
                  xmlWriter.writeEndElement();
              }
  
              xmlWriter.writeEndElement();
          } catch (XMLStreamException e) {
              LOG.error("Not possible to start stream XML");
              throw new ODataRenderException("Not possible to start stream XML: ", e);
          }
      }
docs: Write the 'Metadata Document'.
  
  @throws ODataRenderException if unable to render metadata document