code: def xml(self):
          
  
          self.pendingvalidation()
  
          E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={'xml' : "http://www.w3.org/XML/1998/namespace", 'xlink':"http://www.w3.org/1999/xlink"})
          attribs = {}
          attribs['{http://www.w3.org/XML/1998/namespace}id'] = self.id
  
          #if self.version:
          #    attribs['version'] = self.version
          #else:
          attribs['version'] = FOLIAVERSION
  
          attribs['generator'] = 'pynlpl.formats.folia-v' + LIBVERSION
  
          metadataattribs = {}
          metadataattribs['{' + NSFOLIA + '}type'] = self.metadatatype
  
          if isinstance(self.metadata, ExternalMetaData):
              metadataattribs['{' + NSFOLIA + '}src'] = self.metadata.url
  
          e = E.FoLiA(
              E.metadata(
                  E.annotations(
                      *self.xmldeclarations()
                  ),
                  *self.xmlmetadata(),
                  **metadataattribs
              )
              , **attribs)
          for text in self.data:
              e.append(text.xml())
          return e
docs: Serialise the document to XML.
  
          Returns:
              lxml.etree.Element
  
          See also:
              :meth:`Document.xmlstring`