summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/persistency/outcome/SchemaValidator.java
blob: f2dfa0bedef8b988c3ce780f541adc6880c3fe6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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();
    }

}