From d02e1dbd6808ad6fd0498579de24e7716e31a19d Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Mon, 31 May 2021 15:03:15 +0200
Subject: [PATCH] TMSS-761: Fix to force all derived complexType's to add their
 type as an attribute

---
 lib/siplib.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/siplib.py b/lib/siplib.py
index 2c9a9f4..a4f9faf 100644
--- a/lib/siplib.py
+++ b/lib/siplib.py
@@ -41,6 +41,14 @@ logger = logging.getLogger(__name__)
 VERSION = "SIPlib 0.4"
 ltasip.Namespace.setPrefix('sip')
 
+# The LTA catalogue expectes all lofar complexType objects to be annotated as xsi:type="<my_type>"
+# Trick pyxb into doing this, by override the _RequireXSIType, and make the xsitype required for out types.
+import inspect
+from pyxb.binding.basis import complexTypeDefinition
+for member in inspect.getmembers(ltasip, inspect.isclass):
+    if issubclass(member[1], complexTypeDefinition):
+        member[1]._RequireXSIType = classmethod(lambda _1, _2: True)
+
 # todo: create docstrings for everything.
 # specify types and explain purpose of the field (-> ask someone with more astronomical background)
 
-- 
GitLab