def _parse_schemaloc(self, root): """Parses the ``xsi:schemaLocation`` attribute found on `root`. Returns: A dictionary of namespaces to schema locations. Raises: .XMLSchemaImportError: If `root` did not contain an ``xsi:schemaLocation`` attribute. """ if xmlconst.TAG_SCHEMALOCATION in root.attrib: imports = utils.get_schemaloc_pairs(root) return dict(imports) msg = ("Cannot validate using xsi:schemaLocation. The " "xsi:schemaLocation attribute was not found on the input " "document") raise errors.XMLSchemaImportError(msg)
def _parse_schemaloc(self, root): """Parses the ``xsi:schemaLocation`` attribute found on `root`. Returns: A dictionary of namespaces to schema locations. Raises: .XMLSchemaImportError: If `root` did not contain an ``xsi:schemaLocation`` attribute. """ if xmlconst.TAG_SCHEMALOCATION in root.attrib: imports = utils.get_schemaloc_pairs(root) return dict(imports) msg = ("Cannot validate using xsi:schemaLocation. The " "xsi:schemaLocation attribute was not found on the input " "document") raise errors.XMLSchemaImportError(msg)
def _parse_schemaloc(self, root): """Parses the ``xsi:schemaLocation`` attribute found on `root`. Returns: A dictionary of namespaces to schema locations. Raises: .XMLSchemaImportError: If `root` did not contain an ``xsi:schemaLocation`` attribute. """ try: imports = utils.get_schemaloc_pairs(root) return dict(imports) except KeyError: raise errors.XMLSchemaImportError( "Cannot validate using xsi:schemaLocation. The " "xsi:schemaLocation attribute was not found on the input " "document" )
def test_get_schemaloc_pairs(self): sio = StringIO(XML_SCHEMALOC) root = utils.get_etree_root(sio) pairs = utils.get_schemaloc_pairs(root) self.assertEqual(2, len(pairs))
def test_get_schemaloc_pairs(self): sio = StringIO(XML_SCHEMALOC) root = utils.get_etree_root(sio) pairs = utils.get_schemaloc_pairs(root) self.assertEqual(2, len(list(pairs)))