66from collections .abc import Callable , Sequence
77from random import SystemRandom
88from typing import Any , Union
9+ from xml .parsers .expat import ExpatError
910
1011from defusedxml .minidom import parseString
11- from xml .parsers .expat import ExpatError
1212
1313# Create a safe random number generator
1414
@@ -191,7 +191,7 @@ def default_item_func(parent: str) -> str:
191191def _build_namespace_string (xml_namespaces : dict [str , Any ]) -> str :
192192 """Build XML namespace string from namespace dictionary."""
193193 parts = []
194-
194+
195195 for prefix , value in xml_namespaces .items ():
196196 if prefix == 'xsi' and isinstance (value , dict ):
197197 for schema_att , ns in value .items ():
@@ -203,7 +203,7 @@ def _build_namespace_string(xml_namespaces: dict[str, Any]) -> str:
203203 parts .append (f'xmlns="{ value } "' )
204204 else :
205205 parts .append (f'xmlns:{ prefix } ="{ value } "' )
206-
206+
207207 return ' ' + ' ' .join (parts ) if parts else ''
208208
209209
@@ -701,7 +701,7 @@ def dicttoxml(
701701 """
702702 if xml_namespaces is None :
703703 xml_namespaces = {}
704-
704+
705705 output = []
706706 namespace_str = _build_namespace_string (xml_namespaces )
707707 if root :
0 commit comments