XPathExecutable xexec = xcomp.compile(select);
selector = xexec.load();
// FIXME: Set getVariables
} catch (SaxonApiException sae) {
throw new XProcException(sae);
}
while (source.moreDocuments()) {
// Ok, time to go looking for things to select from.
try {
XdmNode doc = source.read();
if (reader != null) {
logger.trace(MessageFormatter.nodeMessage(reader.getNode(),
reader.getName() + " select read '" + (doc == null ? "null" : doc.getBaseURI()) + "' from " + source));
}
selector.setContextItem(doc);
Iterator<XdmItem> iter = selector.iterator();
while (iter.hasNext()) {
XdmItem item = iter.next();
XdmNode node = null;
try {
node = (XdmNode) item;
} catch (ClassCastException cce) {
throw new XProcException (context, "Select matched non-node!?");
}
XdmDestination dest = new XdmDestination();
S9apiUtils.writeXdmValue(runtime, node, dest, node.getBaseURI());
XdmNode sdoc = dest.getXdmNode();
if (reader != null) {
logger.trace(MessageFormatter.nodeMessage(reader.getNode(),
reader.getName() + " select wrote '" + (sdoc == null ? "null" : sdoc.getBaseURI()) + "' to " + documents));
}
documents.add(sdoc);
}
} catch (SaxonApiException sae) {
throw new XProcException(sae);
}
}
}