Skip to content
Snippets Groups Projects
Commit c0f004b2 authored by Nithya Santhanam's avatar Nithya Santhanam
Browse files
parent f7b8f3e4
No related branches found
No related tags found
No related merge requests found
...@@ -1488,11 +1488,16 @@ class Sip(object): ...@@ -1488,11 +1488,16 @@ class Sip(object):
raise Exception("This SIP does not describe a correlated dataproduct. No subarray pointing available.") raise Exception("This SIP does not describe a correlated dataproduct. No subarray pointing available.")
# this will also validate the document so far # this will also validate the document so far
def get_prettyxml(self): def get_prettyxml(self, schema_location:str = None):
try: try:
dom = self.__sip.toDOM() dom = self.__sip.toDOM()
dom.documentElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") 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() return dom.toprettyxml()
except pyxb.ValidationError as err: except pyxb.ValidationError as err:
logger.error(err.details()) logger.error(err.details())
......
...@@ -8,7 +8,7 @@ logger = logging.getLogger(__name__) ...@@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
d = os.path.dirname(os.path.realpath(__file__)) d = os.path.dirname(os.path.realpath(__file__))
XSDPATH = d+"/LTA-SIP.xsd" XSDPATH = d+"/LTA-SIP.xsd"
DEFAULT_SIP_XSD_PATH = os.path.join(os.environ.get('LOFARROOT', '/opt/lofar'), 'etc', 'lta', 'LTA-SIP.xsd') DEFAULT_SIP_XSD_PATH = os.path.join(os.environ.get('LOFARROOT', '/opt/lofar'), 'share', 'lta', 'LTA-SIP.xsd')
def validate(xmlpath, xsdpath=DEFAULT_SIP_XSD_PATH): def validate(xmlpath, xsdpath=DEFAULT_SIP_XSD_PATH):
'''validates given xml file against given xsd file''' '''validates given xml file against given xsd file'''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment