'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'

def sign_statement(self, statement, node_name, key_file, node_id, id_attr, passphrase=None):

    (_, fil) = make_temp(('%s' % statement), suffix='.xml', decode=False, delete=self._xmlsec_delete_tmpfiles)
    com_list = [self.xmlsec, '--sign', ('--id-attr:%s' % id_attr), node_name]
    if node_id:
        com_list.extend(['--node-id', node_id])
    try:
        (stdout, stderr, signed_statement) = self._run_xmlsec(com_list, [fil], validate_output=False, key_file=key_file, passphrase=passphrase)
        if (stdout == ''):
            if signed_statement:
                return signed_statement
        logger.error(('Signing    operation    failed    :\nstdout    :    %s\nstderr    :    %s' % (stdout, stderr)))
        raise SigverError(stderr)
    except DecryptError:
        raise SigverError('Signing    failed')
