proxy.setOutputProperties(props);
if ("yes".equals(props.getProperty(SaxonOutputKeys.SUPPLY_SOURCE_LOCATOR))) {
if (pipe.getConfiguration().isCompileWithTracing()) {
pipe.getController().addTraceListener(proxy.getTraceListener());
} else {
XPathException de = new XPathException("Cannot use saxon:supply-source-locator unless tracing was enabled at compile time");
de.setErrorCode(SaxonErrorCode.SXSE0002);
throw de;
}
}
//proxy.open();
return proxy;
} else if (result instanceof StreamResult) {
// The "target" is the start of the output pipeline, the Receiver that
// instructions will actually write to (except that other things like a
// NamespaceReducer may get added in front of it). The "emitter" is the
// last thing in the output pipeline, the Receiver that actually generates
// characters or bytes that are written to the StreamResult.
Receiver target;
String method = props.getProperty(OutputKeys.METHOD);
if (method==null) {
target = newUncommittedSerializer(result, props);
target.setPipelineConfiguration(pipe);
return target;
}
Emitter emitter;
CharacterMapExpander characterMapExpander = null;
String useMaps = props.getProperty(SaxonOutputKeys.USE_CHARACTER_MAPS);
if (useMaps != null) {
Controller controller = (pipe == null ? null : pipe.getController());
if (controller == null) {
XPathException de = new XPathException("Cannot use character maps in an environment with no Controller");
de.setErrorCode(SaxonErrorCode.SXSE0001);
throw de;
}
characterMapExpander = controller.makeCharacterMapExpander(useMaps, this);
characterMapExpander.setPipelineConfiguration(pipe);
}
ProxyReceiver normalizer = null;
String normForm = props.getProperty(SaxonOutputKeys.NORMALIZATION_FORM);
if (normForm != null && !normForm.equals("none")) {
normalizer = newUnicodeNormalizer(pipe, props);
}
if ("html".equals(method)) {
emitter = newHTMLEmitter();
emitter.setPipelineConfiguration(pipe);
target = createHTMLSerializer(emitter, props, pipe, characterMapExpander, normalizer);
} else if ("xml".equals(method)) {
emitter = newXMLEmitter();
emitter.setPipelineConfiguration(pipe);
target = createXMLSerializer(emitter, props, pipe, characterMapExpander, normalizer);
} else if ("xhtml".equals(method)) {
emitter = newXHTMLEmitter();
emitter.setPipelineConfiguration(pipe);
target = createXHTMLSerializer(emitter, props, pipe, characterMapExpander, normalizer);
} else if ("text".equals(method)) {
emitter = newTEXTEmitter();
emitter.setPipelineConfiguration(pipe);
target = createTextSerializer(emitter, props, pipe, characterMapExpander, normalizer);
} else if (SaxonOutputKeys.SAXON_XQUERY_METHOD.equals(method)) {
emitter = new XQueryEmitter();
emitter.setPipelineConfiguration(pipe);
props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
target = createXMLSerializer(emitter, props, pipe, characterMapExpander, normalizer);
} else {
Receiver userReceiver;
if (pipe == null) {
throw new XPathException("Unsupported serialization method " + method);
} else {
userReceiver = createUserDefinedOutputMethod(method, props, pipe);
target = userReceiver;
if (userReceiver instanceof Emitter) {
emitter = (Emitter)userReceiver;