Skip to content

Commit

Permalink
Fix #230 XmlSerializer allow empty strings in attribute values
Browse files Browse the repository at this point in the history
  • Loading branch information
tefra committed Aug 12, 2020
1 parent 4f5d247 commit 2112bd2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xsdata/formats/dataclass/serializers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ def set_attribute(element: Element, key: Any, value: Any, namespaces: Namespaces
if key == QNames.XSI_NIL and (element.text or len(element) > 0):
return

if isinstance(value, list) and len(value) == 0:
return

key = SerializeUtils.resolve_qname(key, namespaces)
value = SerializeUtils.resolve_qname(value, namespaces)
value = to_xml(value, namespaces)

if value:
if value is not None:
element.set(key, value)

@staticmethod
Expand Down

0 comments on commit 2112bd2

Please sign in to comment.