]> git.ipfire.org Git - thirdparty/python-drafthorse.git/commitdiff
Improve check for missing namespaces
authorRaphael Michel <michel@rami.io>
Wed, 22 Jan 2025 17:18:55 +0000 (18:18 +0100)
committerRaphael Michel <michel@rami.io>
Wed, 22 Jan 2025 17:18:55 +0000 (18:18 +0100)
drafthorse/models/document.py

index bbdcc11140e8b62f24d1399731c7203d4a6b2a80..b654f92a2d258257e55fba030abf144a87c56f2d 100644 (file)
@@ -121,7 +121,7 @@ class Document(Element):
         # Second pass to ensure all namespaces are defined even if they are unused
         root = ET.fromstring(xml)
         for ns, url in self.__namespaces.items():
-            if ns.encode() not in xml:
+            if f"xmlns:{ns}".encode() not in xml:
                 root.set(f"xmlns:{ns}", url)
         return ET.tostring(root, "utf-8")