* @return null - this implementation of the method never returns a TailCall
*/
public TailCall processLeavingTail(XPathContext context) throws XPathException {
Controller controller = context.getController();
SequenceReceiver out = context.getReceiver();
boolean copyBaseURI = (out.getSystemId() == null);
// if the copy is being attached to an existing parent, it inherits the base URI of the parent
int whichNamespaces = (copyNamespaces ? NodeInfo.ALL_NAMESPACES : NodeInfo.NO_NAMESPACES);
SequenceIterator iter = select.iterate(context);
while (true) {
Item item = iter.next();
if (item == null) {
break;
}
if (item instanceof NodeInfo) {
NodeInfo source = (NodeInfo) item;
int kind = source.getNodeKind();
if (requireDocumentOrElement &&
!(kind == Type.ELEMENT || kind == Type.DOCUMENT)) {
XPathException e = new XPathException("Operand of validate expression must be a document or element node");
e.setXPathContext(context);
e.setErrorCode("XQTY0030");
throw e;
}
switch (kind) {
case Type.ELEMENT: {
Receiver eval = out;
if (validating) {
eval = controller.getConfiguration().getElementValidator(out, source.getNameCode(),
locationId, schemaType, validation);
}
if (copyBaseURI) {
eval.setSystemId(computeNewBaseUri(source));
}
Receiver savedReceiver = null;
PipelineConfiguration savedPipe = null;
if (copyLineNumbers) {
savedReceiver = eval;
savedPipe = new PipelineConfiguration(eval.getPipelineConfiguration());
LocationCopier copier = new LocationCopier(eval);
eval.getPipelineConfiguration().setLocationProvider(copier);
eval = copier;
}
try {
source.copy(eval, whichNamespaces, true, locationId);
} catch (CopyNamespaceSensitiveException e) {
e.setErrorCode((getHostLanguage() == Configuration.XSLT ? "XTTE0950" : "XQTY0086"));
throw e;
}
if (copyLineNumbers) {
eval = savedReceiver;
eval.setPipelineConfiguration(savedPipe);
}
break;
}
case Type.ATTRIBUTE:
try {
copyAttribute(source, schemaType, validation, this, context, rejectDuplicateAttributes);
} catch (NoOpenStartTagException err) {
XPathException e = new XPathException(err.getMessage());
e.setLocator(this);
e.setXPathContext(context);
e.setErrorCode(err.getErrorCodeLocalPart());
throw dynamicError(this, e, context);
}
break;
case Type.TEXT:
out.characters(source.getStringValueCS(), locationId, 0);
break;
case Type.PROCESSING_INSTRUCTION:
if (copyBaseURI) {
out.setSystemId(source.getBaseURI());
}
out.processingInstruction(source.getDisplayName(), source.getStringValueCS(), locationId, 0);
break;
case Type.COMMENT:
out.comment(source.getStringValueCS(), locationId, 0);
break;
case Type.NAMESPACE:
try {
source.copy(out, NodeInfo.NO_NAMESPACES, false, locationId);
} catch (NoOpenStartTagException err) {
XPathException e = new XPathException(err.getMessage());
e.setXPathContext(context);
e.setErrorCode(err.getErrorCodeLocalPart());
//context.getController().recoverableError(e);
throw dynamicError(this, e, context);
}
break;
case Type.DOCUMENT: {
Receiver val = controller.getConfiguration().
getDocumentValidator(out,
source.getBaseURI(),
validation, Whitespace.NONE, schemaType, -1);
val.setPipelineConfiguration(out.getPipelineConfiguration());
if (copyBaseURI) {