def validate_metadata(self, xml):
assert isinstance(xml, basestring)<EOL>if len(xml) == <NUM_LIT:0>:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>errors = []<EOL>res = OneLogin_Saml2_Utils.validate_xml(xml, '<STR_LIT>', self.__debug)<EOL>if not isinstance(res, Document):<EOL><INDENT>errors.append(res)<EOL><DEDENT>else:<EOL><INDENT>dom = res<EOL>element = dom.documentElement<EOL>if element.tagName not in '<STR_LIT>':<EOL><INDENT>errors.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if len(element.getElementsByTagName('<STR_LIT>')) != <NUM_LIT:1>:<EOL><INDENT>errors.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>valid_until = cache_duration = expire_time = None<EOL>if element.hasAttribute('<STR_LIT>'):<EOL><INDENT>valid_until = OneLogin_Saml2_Utils.parse_SAML_to_time(element.getAttribute('<STR_LIT>'))<EOL><DEDENT>if element.hasAttribute('<STR_LIT>'):<EOL><INDENT>cache_duration = element.getAttribute('<STR_LIT>')<EOL><DEDENT>expire_time = OneLogin_Saml2_Utils.get_expire_time(cache_duration, valid_until)<EOL>if expire_time is not None and int(time()) > int(expire_time):<EOL><INDENT>errors.append('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return errors<EOL>
Validates an XML SP Metadata.

:param xml: Metadata's XML that will be validate
:type xml: string

:returns: The list of found errors
:rtype: list