Search in sources :

Example 1 with StringResult

use of org.milyn.payload.StringResult in project tutorials by eugenp.

the class OrderValidator method validate.

public ValidationResult validate(String path) throws IOException, SAXException {
    Smooks smooks = new Smooks(OrderValidator.class.getResourceAsStream("/smooks/smooks-validation.xml"));
    try {
        StringResult xmlResult = new StringResult();
        JavaResult javaResult = new JavaResult();
        ValidationResult validationResult = new ValidationResult();
        smooks.filterSource(new StreamSource(OrderValidator.class.getResourceAsStream(path)), xmlResult, javaResult, validationResult);
        return validationResult;
    } finally {
        smooks.close();
    }
}
Also used : Smooks(org.milyn.Smooks) StreamSource(javax.xml.transform.stream.StreamSource) StringResult(org.milyn.payload.StringResult) ValidationResult(org.milyn.validation.ValidationResult) JavaResult(org.milyn.payload.JavaResult)

Example 2 with StringResult

use of org.milyn.payload.StringResult in project tutorials by eugenp.

the class OrderConverter method convertDocumentWithTempalte.

private String convertDocumentWithTempalte(String path, String config) throws IOException, SAXException {
    Smooks smooks = new Smooks(config);
    try {
        StringResult stringResult = new StringResult();
        smooks.filterSource(new StreamSource(OrderConverter.class.getResourceAsStream(path)), stringResult);
        return stringResult.toString();
    } finally {
        smooks.close();
    }
}
Also used : Smooks(org.milyn.Smooks) StreamSource(javax.xml.transform.stream.StreamSource) StringResult(org.milyn.payload.StringResult)

Aggregations

StreamSource (javax.xml.transform.stream.StreamSource)2 Smooks (org.milyn.Smooks)2 StringResult (org.milyn.payload.StringResult)2 JavaResult (org.milyn.payload.JavaResult)1 ValidationResult (org.milyn.validation.ValidationResult)1