def validate_metadata(self, xml):
assert isinstance(xml, compat.text_types)<EOL>if len(xml) == <NUM_LIT:0>:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>errors = []<EOL>root = OneLogin_Saml2_XML.validate_xml(xml, '<STR_LIT>', self.__debug)<EOL>if isinstance(root, str):<EOL><INDENT>errors.append(root)<EOL><DEDENT>else:<EOL><INDENT>if root.tag != '<STR_LIT>' % OneLogin_Saml2_Constants.NS_MD:<EOL><INDENT>errors.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if (len(root.findall('<STR_LIT>', namespaces=OneLogin_Saml2_Constants.NSMAP))) != <NUM_LIT:1>:<EOL><INDENT>errors.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>valid_until, cache_duration = root.get('<STR_LIT>'), root.get('<STR_LIT>')<EOL>if valid_until:<EOL><INDENT>valid_until = OneLogin_Saml2_Utils.parse_SAML_to_time(valid_until)<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