Search in sources :

Example 1 with XMLStreamWriter2

use of org.codehaus.stax2.XMLStreamWriter2 in project cxf by apache.

the class Stax2ValidationUtils method setupValidation.

public boolean setupValidation(XMLStreamWriter writer, Endpoint endpoint, ServiceInfo serviceInfo) throws XMLStreamException {
    XMLStreamWriter2 writer2 = (XMLStreamWriter2) writer;
    XMLValidationSchema vs = getValidator(endpoint, serviceInfo);
    if (vs == null) {
        return false;
    }
    writer2.setValidationProblemHandler(new ValidationProblemHandler() {

        public void reportProblem(XMLValidationProblem problem) throws XMLValidationException {
            throw new Fault(problem.getMessage(), LOG);
        }
    });
    writer2.validateAgainst(vs);
    return true;
}
Also used : XMLValidationProblem(org.codehaus.stax2.validation.XMLValidationProblem) XMLStreamWriter2(org.codehaus.stax2.XMLStreamWriter2) ValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler) XMLValidationException(org.codehaus.stax2.validation.XMLValidationException) Fault(org.apache.cxf.interceptor.Fault) XMLValidationSchema(org.codehaus.stax2.validation.XMLValidationSchema)

Aggregations

Fault (org.apache.cxf.interceptor.Fault)1 XMLStreamWriter2 (org.codehaus.stax2.XMLStreamWriter2)1 ValidationProblemHandler (org.codehaus.stax2.validation.ValidationProblemHandler)1 XMLValidationException (org.codehaus.stax2.validation.XMLValidationException)1 XMLValidationProblem (org.codehaus.stax2.validation.XMLValidationProblem)1 XMLValidationSchema (org.codehaus.stax2.validation.XMLValidationSchema)1