@staticmethod<EOL><INDENT>def validate_xml(xml, schema, debug=False):<DEDENT>
assert isinstance(schema, compat.str_type)<EOL>try:<EOL><INDENT>xml = OneLogin_Saml2_XML.to_etree(xml)<EOL><DEDENT>except Exception as e:<EOL><INDENT>if debug:<EOL><INDENT>print(e)<EOL><DEDENT>return '<STR_LIT>'<EOL><DEDENT>schema_file = join(dirname(__file__), '<STR_LIT>', schema)<EOL>with open(schema_file, '<STR_LIT:r>') as f_schema:<EOL><INDENT>xmlschema = OneLogin_Saml2_XML._schema_class(etree.parse(f_schema))<EOL><DEDENT>if not xmlschema.validate(xml):<EOL><INDENT>if debug:<EOL><INDENT>print('<STR_LIT>')<EOL>for error in xmlschema.error_log:<EOL><INDENT>print(error.message)<EOL><DEDENT><DEDENT>return '<STR_LIT>'<EOL><DEDENT>return xml<EOL>
Validates a xml against a schema
:param xml: The xml that will be validated
:type xml: str|bytes|xml.dom.minidom.Document|etree.Element
:param schema: The schema
:type schema: string
:param debug: If debug is active, the parse-errors will be showed
:type debug: bool
:returns: Error code or the DomDocument of the xml
:rtype: xml.dom.minidom.Document