class EffectiveServicesMojo extends AbstractVespaDeploymentMojo {

    static String effectiveServices(File servicesFile, ZoneId zone, InstanceName instance) throws Exception {
        Document processedServicesXml = new XmlPreProcessor(servicesFile.getParentFile(),
                                                            servicesFile,
                                                            instance,
                                                            zone.environment(),
                                                            zone.region())
                .run();
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        Writer writer = new StringWriter();
        transformer.transform(new DOMSource(processedServicesXml), new StreamResult(writer));
        return writer.toString().replaceAll("\n(\\s*\n)+","\n");
    }

}