* @param state a stack on which the instruction can save state information during the call on processLeft()
*/
public void processLeft(Stack<XPathContext> contextStack, Stack state) throws XPathException {
XPathContext context = contextStack.peek();
final Controller controller = context.getController();
XPathContext c2 = context.newMinorContext();
c2.setOrigin(this);
Result result;
OutputURIResolver resolver = (href == null ? null : controller.getOutputURIResolver());
if (href == null) {
result = controller.getPrincipalResult();
} else {
try {
String base;
if (resolveAgainstStaticBase) {
base = baseURI;
} else {
base = controller.getCookedBaseOutputURI();
}
String hrefValue = EscapeURI.iriToUri(href.evaluateAsString(context)).toString();
try {
result = resolver.resolve(hrefValue, base);
//System.err.println("Resolver returned " + result);
} catch (Exception err) {
throw new XPathException("Exception thrown by OutputURIResolver", err);
}
if (result == null) {
resolver = StandardOutputResolver.getInstance();
result = resolver.resolve(hrefValue, base);
}
} catch (TransformerException e) {
throw XPathException.makeXPathException(e);
}
}
checkAcceptableUri(context, result);
traceDestination(context, result);
Properties computedLocalProps = gatherOutputProperties(context);
String nextInChain = computedLocalProps.getProperty(SaxonOutputKeys.NEXT_IN_CHAIN);
if (nextInChain != null && nextInChain.length() > 0) {
try {
result = controller.prepareNextStylesheet(nextInChain, baseURI, result);
} catch (TransformerException e) {
throw XPathException.makeXPathException(e);
}
}
// TODO: cache the serializer and reuse it if the serialization properties are fixed at
// compile time (that is, if serializationAttributes.isEmpty). Need to save the serializer
// in a form where the final output destination can be changed.
SerializerFactory sf = c2.getConfiguration().getSerializerFactory();
PipelineConfiguration pipe = controller.makePipelineConfiguration();
pipe.setHostLanguage(Configuration.XSLT);
Receiver receiver = sf.getReceiver(result, pipe, computedLocalProps);
c2.changeOutputDestination(receiver,
true,
validationAction,