@Override
protected void write(final FeatureCollectionResponse featureCollection, OutputStream output,
Operation operation) throws IOException, ServiceException {
// get the transformation we need
TransformInfo info = locateTransformation(featureCollection, operation);
Transformer transformer = repository.getTransformer(info);
// force Xalan to indent the output
if(transformer.getOutputProperties() != null && "yes".equals(transformer.getOutputProperties().getProperty("indent"))) {
try {
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
} catch(IllegalArgumentException e) {
LOGGER.log(Level.FINE, "Could not set indent amount", e);
// in case it's not Xalan
}
}
// prepare the fake operation we're providing to the source output format
final Operation sourceOperation = buildSourceOperation(operation, info);
// lookup the operation we are going to use
final Response sourceResponse = findSourceResponse(sourceOperation, info);
if (sourceResponse == null) {
throw new WFSException(
"Could not locate a response that can generate the desired source format '"
+ info.getSourceFormat() + "' for transformation '" + info.getName() + "'");
}
// prepare the stream connections, so that we can do the transformation on the fly
PipedInputStream pis = new PipedInputStream();