mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix bcf due xsdata update #4680
After https://github.com/tefra/xsdata/commit/93a8ca0548d1f7badb628ad9fd0327672abe140b `parser.register_namespace("xs", "http://www.w3.org/2001/XMLSchema")` started failing with `TypeError: PushParser.register_namespace() missing 1 required positional argument: 'uri'` since xsdata added a new argument `ns_map` (previously it was always using `parse.ns_map` under the hood, now it allows to provide some external dictionary). We just restore the original behaviour with internal `ns_map` by providing it explicitly. Specified xsdata version after that change in pyproject.toml. Also `serialize()` is now using `parser.ns_map` as a fallback value (otherwise why we do `parser.register_namespace` if we never used the `parser.ns_map`?)
This commit is contained in:
@@ -13,7 +13,7 @@ readme = "README.md"
|
|||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
keywords = ["IFC", "BCF", "BIM"]
|
keywords = ["IFC", "BCF", "BIM"]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"xsdata",
|
"xsdata>=24.4",
|
||||||
"numpy",
|
"numpy",
|
||||||
"ifcopenshell",
|
"ifcopenshell",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from xsdata.formats.dataclass.serializers.config import SerializerConfig
|
|||||||
def build_xml_parser(context: Optional[XmlContext] = None) -> XmlParser:
|
def build_xml_parser(context: Optional[XmlContext] = None) -> XmlParser:
|
||||||
"""Return a parser for an XML file."""
|
"""Return a parser for an XML file."""
|
||||||
parser = XmlParser(context=context or XmlContext())
|
parser = XmlParser(context=context or XmlContext())
|
||||||
parser.register_namespace("xs", "http://www.w3.org/2001/XMLSchema")
|
parser.register_namespace(ns_map=parser.ns_map, prefix="xs", uri="http://www.w3.org/2001/XMLSchema")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class XmlParserSerializer:
|
|||||||
"""
|
"""
|
||||||
return self.parser.from_bytes(xml, clazz)
|
return self.parser.from_bytes(xml, clazz)
|
||||||
|
|
||||||
def serialize(self, obj: T, ns_map: Optional[dict[str, str]] = None) -> str:
|
def serialize(self, obj: T, ns_map: Optional[dict[Optional[str], str]] = None) -> str:
|
||||||
"""
|
"""
|
||||||
Serialize an object to XML.
|
Serialize an object to XML.
|
||||||
|
|
||||||
@@ -79,5 +79,5 @@ class XmlParserSerializer:
|
|||||||
Returns:
|
Returns:
|
||||||
The XML as string.
|
The XML as string.
|
||||||
"""
|
"""
|
||||||
ns_map = ns_map or {"xs": "http://www.w3.org/2001/XMLSchema"}
|
ns_map = ns_map or self.parser.ns_map or {"xs": "http://www.w3.org/2001/XMLSchema"}
|
||||||
return self.serializer.render(obj, ns_map)
|
return self.serializer.render(obj, ns_map)
|
||||||
|
|||||||
Reference in New Issue
Block a user