protected Receiver getReceiver(Configuration config,
Controller controller,
Properties predefinedProperties) throws SaxonApiException {
try {
SerializerFactory sf = config.getSerializerFactory();
PipelineConfiguration pipe =
(controller == null ? config.makePipelineConfiguration() :
controller.makePipelineConfiguration());
// A controller is needed for processing character maps
Properties props = new Properties();
for (Property p : properties.keySet()) {
String value = properties.get(p);
props.setProperty(p.toString(), value);
}
if (predefinedProperties != null) {
Enumeration eps = predefinedProperties.propertyNames();
while (eps.hasMoreElements()) {
String name = (String)eps.nextElement();
String value = predefinedProperties.getProperty(name);
if (props.getProperty(name) == null) {
props.setProperty(name, value);
} else if (name.equals(OutputKeys.CDATA_SECTION_ELEMENTS) || name.equals(SaxonOutputKeys.SUPPRESS_INDENTATION)) {
props.setProperty(name, props.getProperty(name) + " " + value);
}
}
}
return sf.getReceiver(result, pipe, props);
} catch (XPathException e) {
throw new SaxonApiException(e);
}
}