From 28d1178c807cd241526d7e34be804545fc0ef078 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Fri, 30 Apr 2021 10:32:50 +0200
Subject: [PATCH] TMSS-717: SIP schema location and namespace. Why does xml
 make everything so much harder than json?

---
 lib/siplib.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/siplib.py b/lib/siplib.py
index e81b00e..71b7c18 100644
--- a/lib/siplib.py
+++ b/lib/siplib.py
@@ -1488,11 +1488,16 @@ class Sip(object):
             raise Exception("This SIP does not describe a correlated dataproduct. No subarray pointing available.")
 
     # this will also validate the document so far
-    def get_prettyxml(self):
+    def get_prettyxml(self, schema_location:str = None):
         try:
             dom = self.__sip.toDOM()
             dom.documentElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
-            dom.documentElement.setAttribute('xsi:schemaLocation', "http://www.astron.nl/SIP-Lofar LTA-SIP-2.7.0.xsd")
+            if schema_location is None:
+                # this is/was the default schema location, even though we never hosted the xsd at the astron server
+                # That makes xmllint fail to validate (because the schema obviously can't be found)
+                schema_location = "http://www.astron.nl/SIP-Lofar LTA-SIP-2.7.2.xsd"
+            dom.documentElement.setAttribute('xsi:schemaLocation', schema_location)
+            dom.documentElement.setAttribute('xmlns:sip', schema_location.split(' ')[0])
             return dom.toprettyxml()
         except pyxb.ValidationError as err:
             logger.error(err.details())
-- 
GitLab