Search in sources :

Example 1 with DMN_VERSION

use of org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller.DMN_VERSION in project drools by kiegroup.

the class DMNValidatorImpl method validateSchema.

private List<DMNMessage> validateSchema(String xml, String path) {
    List<DMNMessage> problems = new ArrayList<>();
    try {
        DMN_VERSION inferDMNVersion = XStreamMarshaller.inferDMNVersion(new StringReader(xml));
        Schema usingSchema = determineSchema(inferDMNVersion);
        Source s = new StreamSource(new StringReader(xml));
        validateSchema(s, usingSchema);
    } catch (Exception e) {
        problems.add(new DMNMessageImpl(DMNMessage.Severity.ERROR, MsgUtil.createMessage(Msg.FAILED_XML_VALIDATION, e.getMessage()), Msg.FAILED_XML_VALIDATION.getType(), null, e).withPath(path));
    }
    return problems;
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) Schema(javax.xml.validation.Schema) StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) DMN_VERSION(org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller.DMN_VERSION) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) DMNMessageImpl(org.kie.dmn.core.impl.DMNMessageImpl)

Aggregations

IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Source (javax.xml.transform.Source)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Schema (javax.xml.validation.Schema)1 DMNMessage (org.kie.dmn.api.core.DMNMessage)1 DMN_VERSION (org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller.DMN_VERSION)1 DMNMessageImpl (org.kie.dmn.core.impl.DMNMessageImpl)1 SAXException (org.xml.sax.SAXException)1