@@ -251,11 +251,9 @@ def build_xml_element(data, parent=None):
251
251
parent = ET .Element (data .__class__ .__name__ )
252
252
253
253
attrs = attr .fields (data .__class__ )
254
- id_attribute_value = (
255
- None # Store id attribute value to be set after other attributes
256
- )
254
+ id_attribute_value = None # Store id attribute value to be set after other attributes
257
255
for aattr in attrs :
258
- if aattr .name == "id" :
256
+ if aattr .name == 'id' :
259
257
id_attribute_value = data .__getattribute__ (aattr .name )
260
258
elif isinstance (aattr .default , attr .Factory ):
261
259
children = data .__getattribute__ (aattr .name )
@@ -265,7 +263,7 @@ def build_xml_element(data, parent=None):
265
263
for child in children :
266
264
child_element = build_xml_element (child )
267
265
parent .append (child_element )
268
-
266
+
269
267
# Filters name space and schemaLoacation attributes, only allows non name space attributes to added as attributes
270
268
elif not any (
271
269
hasattr (data , attr_name )
@@ -274,22 +272,21 @@ def build_xml_element(data, parent=None):
274
272
attribute_name = aattr .name
275
273
attribute_value = data .__getattribute__ (aattr .name )
276
274
parent .set (attribute_name , str (attribute_value ))
277
-
275
+
278
276
# This defines the various namespaces and schemaLocation of the generated xml
279
277
if hasattr (data , "xmlns" ):
280
278
parent .set ("xmlns" , data .xmlns )
281
279
if hasattr (data , "xmlns_url" ):
282
280
parent .set ("xmlns:xsi" , data .xmlns_url )
283
281
if hasattr (data , "xmlns_loc" ):
284
- parent .set ("xsi:schemaLocation" , str (data .xmlns_loc + "\n " + data .xmln_loc_2 ))
282
+ parent .set ("xsi:schemaLocation" , str (data .xmlns_loc + " " + data .xmln_loc_2 ))
285
283
286
284
# Set the id attribute after processing all other attributes
287
285
if id_attribute_value is not None :
288
286
parent .set ("id" , str (id_attribute_value ))
289
287
290
288
return parent
291
289
292
-
293
290
def ascii_encode_dict (data ):
294
291
ascii_encode = (
295
292
lambda x : x .encode ("ascii" )
0 commit comments