Exception error = null;
if ("runtime-error".equals(scenario)) {
try {
//compile
CompiledXQuery compiled = xquery.compile(context, new FileSource(caseScript, "UTF8", true));
//execute
result = xquery.execute(compiled, contextSequence);
if (outputFiles.getLength() != 0) {
//can be answered
for (int i = 0; i < outputFiles.getLength(); i++) {
ElementImpl outputFile = (ElementImpl)outputFiles.item(i);
String compare = outputFile.getAttribute("compare");
if (compare != null && compare.equalsIgnoreCase("IGNORE")) {
ok = true;
break;
}
if (compareResult(script, "XQTS_1_0_3/ExpectedTestResults/"+folder, outputFile, result)) {
ok = true;
break;
}
}
} else {
error = catchError(result);
}
} catch (Exception e) {
error = e;
}
if (!ok && error != null && expectedError != null) {// error.getMessage().contains(expectedError)) {
ok = true;
}
} else {
//compile
CompiledXQuery compiled = xquery.compile(context, new FileSource(caseScript, "UTF8", true));
//execute
result = xquery.execute(compiled, contextSequence);
//check answer