From 0e98340287e4a0289f181a2907e3cf348d40d587 Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Wed, 6 Jul 2016 13:21:46 +0200
Subject: [PATCH] Handling non-wellformed Xml files issuing warnings

---
 ws/Unitmarking/.gitignore                     |  1 +
 .../xsd/InstanceSetEvaluation.java            | 25 +++++--------------
 2 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/ws/Unitmarking/.gitignore b/ws/Unitmarking/.gitignore
index a1c3ab4d0..791f189b0 100644
--- a/ws/Unitmarking/.gitignore
+++ b/ws/Unitmarking/.gitignore
@@ -2,3 +2,4 @@
 /.settings/
 .classpath
 .project
+/A1.log
diff --git a/ws/Unitmarking/src/main/java/de/hdm_stuttgart/mi/unitmarking/xsd/InstanceSetEvaluation.java b/ws/Unitmarking/src/main/java/de/hdm_stuttgart/mi/unitmarking/xsd/InstanceSetEvaluation.java
index eb30f8309..094805fcb 100644
--- a/ws/Unitmarking/src/main/java/de/hdm_stuttgart/mi/unitmarking/xsd/InstanceSetEvaluation.java
+++ b/ws/Unitmarking/src/main/java/de/hdm_stuttgart/mi/unitmarking/xsd/InstanceSetEvaluation.java
@@ -35,18 +35,10 @@ public class InstanceSetEvaluation {
 	private static Logger log = LogManager.getLogger(InstanceSetEvaluation.class);
 
 	final static List<InstanceTest> tests = new Vector<>();
+	final static StringBuffer warnings = new StringBuffer();
 
 	final StringBuffer messages = new StringBuffer(), errorMessages = new StringBuffer();
 
-	/**
-	 * @param args unused
-	 */
-	public static void main(String[] args) {
-		final InstanceSetEvaluation ise = new InstanceSetEvaluation("SchemaTest", "Schema/dictionary.xsd");
-		System.out.println(ise.getMessages());
-		System.out.println("All tests succeeded:" + ise.allTestsSucceeded);
-	}
-
 	/**
 	 * @return Individual failed test(s) error message(s).
 	 */
@@ -58,7 +50,7 @@ public class InstanceSetEvaluation {
 	 * @return Individual test's and aggregated results.
 	 */
 	public String getMessages() {
-		return "\n" + messages.toString();
+		return "\n" + warnings.toString() +  "\n" + messages.toString();
 	}
 
 	/**
@@ -126,20 +118,15 @@ public class InstanceSetEvaluation {
 				tests.add(new InstanceTest(xmlTestList.get(0), xmlTestFileDir, xsdSchemaFilename, instanceFilename));
 				break;
 			default:
-				log.error("Fatal: Found " + xmlTestList.size() +
-						" <?xmltest ... ?> annotations in file '" + 
-						instanceFilename + "'");
-				System.exit(1);
+				warnings.append("Found " + xmlTestList.size() + "' annotations in file '" +  instanceFilename.getPath() + "'\n");
 			}        
 
 		} catch (final JDOMException e) {
-			log.fatal("Document '" + instanceFilename.getPath() +
+			log.error("Document '" + instanceFilename.getPath() +
 					"' is invalid:", e);
-			System.exit(1);
+			warnings.append("Unable to parse document " + instanceFilename.getPath() + ": " + e + "\n");
 		} catch (final IOException e) {
-			log.fatal("Unable to open '" + instanceFilename.getPath() + 
-					"' for reading:", e);
-			System.exit(1);
+			warnings.append("Unable to read document " + instanceFilename.getPath() + ": " + e + "\n");
 		}
 	}
 }
-- 
GitLab