Search in sources :

Example 1 with SchematronValidationException

use of org.apache.camel.component.schematron.exception.SchematronValidationException in project camel by apache.

the class SchematronProcessor method validate.

/**
     * Validates the given XML for given Rules.
     *
     * @param xml
     * @return
     */
public String validate(final String xml) {
    try {
        final Source source = new SAXSource(reader, new InputSource(IOUtils.toInputStream(xml)));
        final StringWriter writer = new StringWriter();
        templates.newTransformer().transform(source, new StreamResult(writer));
        return writer.toString();
    } catch (TransformerException e) {
        logger.error(e.getMessage());
        throw new SchematronValidationException("Failed to apply Schematron validation transform", e);
    }
}
Also used : InputSource(org.xml.sax.InputSource) SchematronValidationException(org.apache.camel.component.schematron.exception.SchematronValidationException) SAXSource(javax.xml.transform.sax.SAXSource) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) InputSource(org.xml.sax.InputSource) SAXSource(javax.xml.transform.sax.SAXSource) Source(javax.xml.transform.Source) TransformerException(javax.xml.transform.TransformerException)

Aggregations

StringWriter (java.io.StringWriter)1 Source (javax.xml.transform.Source)1 TransformerException (javax.xml.transform.TransformerException)1 SAXSource (javax.xml.transform.sax.SAXSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 SchematronValidationException (org.apache.camel.component.schematron.exception.SchematronValidationException)1 InputSource (org.xml.sax.InputSource)1