XdmNode keyDoc;
try {
keyDoc = doc.build(new StreamSource(new StringReader(key.toString())));
eval.setExternalVariable(new QName("key"), keyDoc);
eval.setExternalVariable(new QName("uri"), new XdmAtomicValue("value.txt"));
} catch (SaxonApiException e) {
e.printStackTrace();
}
//System.out.print(System.currentTimeMillis()-time_stamp+", ");
//if streaming is not enabled (no need to write input to file)
} else {
StringBuffer values = new StringBuffer();
values.append("<root>");
for (Text inputValue : inputValues) {
values.append(inputValue.toString().trim().replaceAll("\n", "").replaceAll("\t", ""));
//counter++;
}
values.append("</root>");
//System.out.println("Length of input: " + counter);
//System.out.println("###VALUES###:\n" + values);
//System.out.print(System.currentTimeMillis()-time_stamp+", ");
XdmNode keyDoc;
XdmNode valDoc;
try {
keyDoc = doc.build(new StreamSource(new StringReader(key.toString())));
valDoc = doc.build(new StreamSource(new StringReader(values.toString())));
eval.setExternalVariable(new QName("key"), keyDoc);
eval.setExternalVariable(new QName("value"), valDoc);
} catch (SaxonApiException e) {
e.printStackTrace();
}
}