if (compile) {
if ("parse-error".equals(testCase.getAttributeValue(scenarioAtt))) {
continue;
}
QueryCompiler qc = new QueryCompiler(saConfig);
qc.setBaseURI(new File(absQueryName).toURI().toString());
String groupName = testCase.getParent().getAttributeValue(nameAtt);
groupName = lowercase(groupName);
if (groupName.equals(prevGroup)) {
groupsize++;
int tome = groupsize / 500;
if (tome != 0) {
groupName += tome;
}
} else {
groupsize = 0;
prevGroup = groupName;
}
queryName = lowercase(queryName);
qc.setClassName(makeClassName(groupName, queryName));
File dir = new File(saxonDir + "/java/");
dir.mkdir();
qc.setOutputDirectory(dir);
//qc.setClassPath(classPath);
try {
qc.compileQueryToJava(new FileInputStream(absQueryName), "utf8");
log.println("Java source code written "/* + qc.getJavaFile()*/);
String finaldir = dir + "/" + groupName;
if (!directories.contains(finaldir)) {
compileScript.write("%JAVA%\\bin\\javac -classpath %CLASSPATH% " + finaldir + "/*.java\n");
directories.add(finaldir);
}
} catch (XPathException err) {
log.println("Query compilation failed");
continue;
} catch (FileNotFoundException err) {
log.println("Query file not found");
} catch (Exception err2) {
err2.printStackTrace();
continue;
}
continue;
} else {
if (runCompiled) {
if ("parse-error".equals(testCase.getAttributeValue(scenarioAtt))) {
continue;
}
QueryCompiler qc = new QueryCompiler(saConfig);
qc.setBaseURI(new File(absQueryName).toURI().toString());
String groupName = testCase.getParent().getAttributeValue(nameAtt);
groupName = lowercase(groupName);
if (groupName.equals(prevGroup)) {
groupsize++;
int tome = groupsize / 500;
if (tome != 0) {
groupName += tome;
}
} else {
groupsize = 0;
prevGroup = groupName;
}
queryName = lowercase(queryName);
qc.setClassName(makeClassName(groupName, queryName));
File dir = new File(saxonDir + "/java/");
dir.mkdir();
qc.setOutputDirectory(dir);
DynamicQueryContext dqc = new DynamicQueryContext(saConfig);
dqc.setParameterValue("zlsJJ", StringValue.EMPTY_STRING);
NodeInfo contextItemElement = getChildElement(testCase, contextItemNT);
if (contextItemElement != null) {
DocumentInfo contextNode = loadDocument(contextItemElement.getStringValue());
dqc.setContextItem(contextNode);
}
processInputDocuments(testCase, inputFileNT, variableAtt, dqc);
setQueryParameters(catalog, testCase, dqc, inputUriNT, variableAtt, collectionNT, idAtt);
NodeInfo defaultCollection = getChildElement(testCase, defaultCollectionNT);
if (defaultCollection != null) {
String docName = defaultCollection.getStringValue();
NodeInfo collectionElement = getCollectionElement(catalog, docName, collectionNT, idAtt);
CollectionURIResolver r =
new XQTSCollectionURIResolver(catalog, collectionElement, true);
saConfig.setCollectionURIResolver(r);
}
processInputQueries(testCase, inputQueryNT, variableAtt, nameAtt, filePath, dqc);
String outputDir = saxonDir + "/results/" + filePath;
new File(outputDir).mkdirs();
outputFile = outputDir + "/" + testName + ".out";
File outputFileF = new File(outputFile);
outputFileF.createNewFile();
StreamResult result = new StreamResult(outputFileF);
try {
qc.runQuery(dqc, result, outputProps);
} catch (XPathException err) {
if (!err.hasBeenReported()) {
log.println(err.getMessage());
}
processError(err, testCase, testName, filePath + queryName + ".xq", expectedErrorNT, specVersionAtt);