From c937f2abf32c8dc4dbf047690a119c96ed6cc938 Mon Sep 17 00:00:00 2001
From: imcovangent <I.vanGent@tudelft.nl>
Date: Tue, 23 Oct 2018 16:22:06 +0200
Subject: [PATCH] Small improvements and bug fix for schema validation.

Former-commit-id: 68d078287d4f4f8e21244cbdbc4718e19356480d
---
 kadmos/graph/graph_kadmos.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/kadmos/graph/graph_kadmos.py b/kadmos/graph/graph_kadmos.py
index dbcbe5ef5..5a4b5b042 100644
--- a/kadmos/graph/graph_kadmos.py
+++ b/kadmos/graph/graph_kadmos.py
@@ -5339,9 +5339,11 @@ def _perform_check_list(io_list, check_list, keep_running=False):
         _check_leafs(io_list, leafs, keep_running=keep_running)
 
     # Check file against XSD schema
-    if xsd_check:
+    if xsd_check and io_list:
+        logger.info('Checking for invalidities w.r.t. schema...')
         schema_path = _get_data_schema(os.path.split(io_list[0][0])[0])
-        _validate_file_against_schema(io_list[0][0], schema_path, keep_running=keep_running)
+        for item in io_list:
+            _validate_file_against_schema(item[0], schema_path, keep_running=keep_running)
 
     return
 
@@ -5639,7 +5641,7 @@ def _get_data_schema(kb_dir):
         raise IOError('No XML Schemas (.xsd files) found in the knowledge base ({}). '
                       'One .xsd file is required per knowledge base.'.format(os.path.split(kb_dir)[1]))
     else:
-        logger.info("XML Schema '{}' found.".format(data_schema))
+        logger.info("   XML Schema '{}' found.".format(data_schema))
 
     return os.path.join(kb_dir, data_schema)
 
@@ -5651,7 +5653,6 @@ def _validate_file_against_schema(file_path, schema_path, keep_running=False):
 
     :rtype: Error
     """
-    logger.info('Checking for invalidities w.r.t. schema')
     # Parse the XML file
     tree = etree.parse(file_path)
 
@@ -5662,10 +5663,10 @@ def _validate_file_against_schema(file_path, schema_path, keep_running=False):
     # Perform file validation
     validated = xmlschema.validate(tree)
     if validated:
-        logger.info('The XML file {} has been validated against the schema {}.'.format(os.path.split(file_path)[1],
+        logger.info('   The XML file {} has been validated against the schema {}.'.format(os.path.split(file_path)[1],
                     os.path.split(schema_path)[1]))
     else:
-        logger.debug('Schema validation errors:')
+        logger.debug('   Schema validation errors:')
         for error in xmlschema.error_log:
             logger.debug('ERROR ON LINE {} in file {}: {}'.format(error.line, os.path.split(file_path)[1],
                                                                   error.message.encode("utf-8")))
-- 
GitLab