}
protected static Document transform( Document doc,
String schemaUri,
int numExpectedMismatchedValues ) {
Results results = schemas.validate(doc, schemaUri);
if (print) System.out.println(results);
if (numExpectedMismatchedValues > 0) {
assertThat("expected mismatch errors, but found none", results.hasOnlyTypeMismatchErrors(), is(true));
assertThat("expected different number of mismatches", results.errorCount(), is(numExpectedMismatchedValues));
} else {
assertThat("expected no mismatch errors", results.hasOnlyTypeMismatchErrors(), is(false));
assertThat("expected to find problems", results.hasProblems(), is(false));
}
Document output = schemas.convertValues(doc, results);
if (numExpectedMismatchedValues > 0) {
assertThat(output, is(not(sameInstance(doc))));
// Now double check that the output is valid ...
Results newResults = schemas.validate(output, schemaUri);
assertThat(newResults.hasErrors(), is(false));
if (print) {
System.out.println("After converting: " + output);
System.out.println(newResults);
}
} else {