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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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"
            )
Exemplo n.º 4
0
 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))
Exemplo n.º 5
0
 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)))