return list.iterator();
}
public TailCall processLeavingTail(XPathContext context) throws XPathException {
Controller controller = context.getController();
XPathContext c2 = context.newMinorContext();
c2.setOrigin(this);
Result result;
OutputURIResolver resolver = null;
if (href == null) {
result = controller.getPrincipalResult();
} else {
try {
resolver = controller.getOutputURIResolver();
String hrefValue = href.evaluateAsString(context);
result = resolver.resolve(hrefValue, controller.getPrincipalResultURI());
if (result == null) {
resolver = StandardOutputResolver.getInstance();
result = resolver.resolve(hrefValue, controller.getPrincipalResultURI());
}
} catch (TransformerException e) {
throw XPathException.wrap(e);
}
}
boolean timing = controller.getConfiguration().isTiming();
if (timing) {
String dest = result.getSystemId();
if (dest == null) {
if (result instanceof StreamResult) {
dest = "anonymous output stream";
} else if (result instanceof SAXResult) {
dest = "SAX2 ContentHandler";
} else if (result instanceof DOMResult) {
dest = "DOM tree";
} else {
dest = result.getClass().getName();
}
}
System.err.println("Writing to " + dest);
}
Properties props = outputProperties;
if (serializationAttributes.size() > 0) {
props = new Properties(outputProperties);
final NamePool namePool = context.getController().getNamePool();
for (Iterator it = serializationAttributes.keySet().iterator(); it.hasNext();) {
Integer key = (Integer) it.next();
Expression exp = (Expression) serializationAttributes.get(key);
String value = exp.evaluateAsString(context);
try {
setSerializationProperty(props, key.intValue(), value, namePool, nsResolver);
} catch (DynamicError e) {
e.setXPathContext(context);
e.setLocator(getSourceLocator());
throw e;
}
}
}
String nextInChain = outputProperties.getProperty(SaxonOutputKeys.NEXT_IN_CHAIN);
if (nextInChain != null) {
try {
result = controller.prepareNextStylesheet(nextInChain, baseURI, result);
} catch (TransformerException e) {
throw XPathException.wrap(e);
}
}
c2.changeOutputDestination(props,
result,
true,
validationAction,
schemaType);
processChildren(c2);
SequenceReceiver out = c2.getReceiver();
out.close();
if (resolver != null) {
try {
resolver.close(result);
} catch (TransformerException e) {