summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/persistency/outcome/SchemaValidator.java
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/persistency/outcome/SchemaValidator.java')
-rwxr-xr-xsource/com/c2kernel/persistency/outcome/SchemaValidator.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/source/com/c2kernel/persistency/outcome/SchemaValidator.java b/source/com/c2kernel/persistency/outcome/SchemaValidator.java
new file mode 100755
index 0000000..f2dfa0b
--- /dev/null
+++ b/source/com/c2kernel/persistency/outcome/SchemaValidator.java
@@ -0,0 +1,54 @@
+package com.c2kernel.persistency.outcome;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import org.exolab.castor.xml.schema.reader.SchemaReader;
+import org.xml.sax.InputSource;
+
+
+/**************************************************************************
+ *
+ * $Revision: 1.2 $
+ * $Date: 2005/04/26 06:48:13 $
+ *
+ * Copyright (C) 2003 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+
+
+public class SchemaValidator extends OutcomeValidator {
+
+ org.exolab.castor.xml.schema.Schema castorSchema;
+ /**
+ *
+ */
+
+ public SchemaValidator() {
+
+ }
+
+ public org.exolab.castor.xml.schema.Schema getSOM() {
+ return castorSchema;
+ }
+
+ /**
+ *
+ */
+
+ public synchronized String validate(String outcome) {
+ errors = new StringBuffer();
+ try {
+ InputSource schemaSource = new InputSource(new StringReader(outcome));
+ SchemaReader mySchemaReader = new SchemaReader(schemaSource);
+ mySchemaReader.setErrorHandler(this);
+ mySchemaReader.setValidation(true);
+ castorSchema = mySchemaReader.read();
+ } catch (IOException e) {
+ errors.append(e.getMessage());
+ }
+ return errors.toString();
+ }
+
+}