throw new XPathException("Either a source document or an initial template must be specified");
}
} else {
Mode mode = preparedStylesheet.getRuleManager().getMode(initialMode, false);
if (mode == null || (initialMode != null && mode.isEmpty())) {
throw new XPathException("Requested initial mode " +
(initialMode == null ? "" : initialMode.getDisplayName()) +
" does not exist", "XTDE0045");
}
if (source.getSystemId() != null) {
registerDocument(source.getDocumentRoot(), new DocumentURI(source.getSystemId()));
}
}
// System.err.println("*** TransformDocument");
if (executable==null) {
throw new XPathException("Stylesheet has not been compiled");
}
openMessageEmitter();
XPathContextMajor initialContext = newXPathContext();
if (source != null) {
initialContextItem = source;
contextForGlobalVariables = source.getRoot();
SequenceIterator currentIter = SingletonIterator.makeIterator(source);
if (initialTemplate != null) {
currentIter.next();
}
initialContext.setCurrentIterator(currentIter);
}
initializeController();
PipelineConfiguration pipe = makePipelineConfiguration();
Receiver result = openResult(pipe, initialContext, target, ResultDocument.APPEND_CONTENT);
// Process the source document by applying template rules to the initial context node
if (initialTemplate == null) {
initialContextItem = source;
Mode mode = getRuleManager().getMode(initialMode, false);
if (mode == null || (initialMode != null && mode.isEmpty())) {
throw new XPathException("Requested initial mode " +
(initialMode == null ? "" : initialMode.getDisplayName()) +
" does not exist", "XTDE0045");
}
TailCall tc = ApplyTemplates.applyTemplates(