@@ -115,7 +115,7 @@ def __setattr__(self, key, value):
115
115
SamlBase .__setattr__ (self , key , value )
116
116
117
117
def verify (self ):
118
- if not self .text :
118
+ if not self .text and not self . extension_elements :
119
119
if not self .extension_attributes :
120
120
raise Exception (
121
121
"Attribute value base should not have extension attributes"
@@ -293,11 +293,26 @@ def harvest_element_tree(self, tree):
293
293
self ._convert_element_tree_to_member (child )
294
294
for attribute , value in iter (tree .attrib .items ()):
295
295
self ._convert_element_attribute_to_member (attribute , value )
296
- if tree .text :
296
+
297
+ # if we have added children to this node
298
+ # we consider whitespace insignificant
299
+ # and remove/trim/strip whitespace
300
+ # and expect to not have actual text content
301
+ text = (
302
+ tree .text .strip ()
303
+ if tree .text and self .extension_elements
304
+ else tree .text
305
+ )
306
+ if text :
297
307
#print("set_text:", tree.text)
298
308
# clear type
299
309
#self.clear_type()
300
- self .set_text (tree .text )
310
+ self .set_text (text )
311
+
312
+ # if we have added a text node
313
+ # or other children to this node
314
+ # remove the nil marker
315
+ if text or self .extension_elements :
301
316
if XSI_NIL in self .extension_attributes :
302
317
del self .extension_attributes [XSI_NIL ]
303
318
0 commit comments