code: def sign_statement(self, statement, node_name, key_file, node_id, id_attr):
          
          if isinstance(statement, SamlBase):
              statement = str(statement)
  
          _, fil = make_temp(
              statement,
              suffix='.xml',
              decode=False,
              delete=self._xmlsec_delete_tmpfiles,
          )
  
          com_list = [
              self.xmlsec,
              '--sign',
              '--privkey-pem', key_file,
              '--id-attr:{id_attr_name}'.format(id_attr_name=id_attr),
              node_name,
          ]
  
          if node_id:
              com_list.extend(['--node-id', node_id])
  
          try:
              (stdout, stderr, output) = self._run_xmlsec(com_list, [fil])
          except XmlsecError as e:
              raise SignatureError(com_list)
  
          # this does not work if --store-signatures is used
          if output:
              return output.decode("utf-8")
          if stdout:
              return stdout.decode("utf-8")
          raise SignatureError(stderr)
docs: Sign an XML statement.
  
          :param statement: The statement to be signed
          :param node_name: string like 'urn:oasis:names:...:Assertion'
          :param key_file: The file where the key can be found
          :param node_id:
          :param id_attr: The attribute name for the identifier, normally one of
              'id','Id' or 'ID'
          :return: The signed statement