diff --git a/basyx/aas/adapter/xml/xml_deserialization.py b/basyx/aas/adapter/xml/xml_deserialization.py index b5899c9fd..e42a9a6f6 100644 --- a/basyx/aas/adapter/xml/xml_deserialization.py +++ b/basyx/aas/adapter/xml/xml_deserialization.py @@ -87,7 +87,7 @@ def _tag_replace_namespace(tag: str, nsmap: Dict[str, str]) -> str: """ split = tag.split("}") for prefix, namespace in nsmap.items(): - if namespace == split[0][1:]: + if prefix and namespace == split[0][1:]: return prefix + ":" + split[1] return tag diff --git a/test/adapter/xml/test_xml_deserialization.py b/test/adapter/xml/test_xml_deserialization.py index f562e02a6..9310e4462 100644 --- a/test/adapter/xml/test_xml_deserialization.py +++ b/test/adapter/xml/test_xml_deserialization.py @@ -221,7 +221,7 @@ def test_operation_variable_no_submodel_element(self) -> None: """) - self._assertInExceptionAndLog(xml, "aas:value", KeyError, logging.ERROR) + self._assertInExceptionAndLog(xml, ["aas:value", "has no submodel element"], KeyError, logging.ERROR) def test_operation_variable_too_many_submodel_elements(self) -> None: # TODO: simplify this should our suggestion regarding the XML schema get accepted @@ -256,6 +256,7 @@ def test_operation_variable_too_many_submodel_elements(self) -> None: with self.assertLogs(logging.getLogger(), level=logging.WARNING) as context: read_aas_xml_file(io.BytesIO(xml.encode("utf-8")), failsafe=False) self.assertIn("aas:value", context.output[0]) # type: ignore + self.assertIn("more than one submodel element", context.output[0]) def test_duplicate_identifier(self) -> None: xml = _xml_wrap(""" @@ -306,7 +307,7 @@ def get_clean_store() -> model.DictObjectStore: with self.assertLogs(logging.getLogger(), level=logging.INFO) as log_ctx: identifiers = read_aas_xml_file_into(object_store, bytes_io, replace_existing=False, ignore_existing=True) self.assertEqual(len(identifiers), 0) - self.assertIn("already exists in the object store", log_ctx.output[0]) # type: ignore + self.assertIn("already exists in the object store", log_ctx.output[0]) submodel = object_store.pop() self.assertIsInstance(submodel, model.Submodel) self.assertEqual(submodel.id_short, "test123")