Skip to content

Commit

Permalink
Fix invalid xml serialization of DateTime value
Browse files Browse the repository at this point in the history
Serialization emitted wrong string for the XML dateTime type

Wrong: <uax:DateTime>2020-01-31 12:00:00</uax:DateTime>
Correct: <uax:DateTime>2020-01-31T12:00:00</uax:DateTime>

Notice the missing T seperator in the text representation of the value
attribute.

In XML the parser expects a string according to this format.
https://www.w3.org/TR/xmlschema-2/#dateTime

Fixes issue #1343
  • Loading branch information
Christian Unterberger authored and oroulet committed Oct 9, 2021
1 parent 3012acf commit 9c12685
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions opcua/common/xmlexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ def _val_to_etree(self, el, dtype, val):
val = b""
data = base64.b64encode(val)
el.text = data.decode("utf-8")
elif dtype == ua.NodeId(ua.ObjectIds.DateTime):
el.text = val.isoformat()
elif not hasattr(val, "ua_types"):
if isinstance(val, bytes):
# FIXME: should we also encode this (localized text I guess) using base64??
Expand Down

0 comments on commit 9c12685

Please sign in to comment.