@Override
    public void save(FacetList fl) {
	PrintStream out;
	boolean close;

	if (outputDir == null) {
	    close = false;
	    out = System.out;
	} else {
	    close = true;
	    try {
		out = new PrintStream(outputDir.resolve(fl.getSourceShort()).toFile());
	    } catch (FileNotFoundException e) {
		logger.error(e.getMessage(), e);
		return;
	    }
	}

	try {
	    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
	    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

	    Document doc = docBuilder.newDocument();
	    Element rootElement = doc.createElement("fieldList");
	    doc.appendChild(rootElement);

	    for (Map.Entry<String, String> e : fl.res.entrySet()) {
		Element field = doc.createElement("field");
		rootElement.appendChild(field);
		field.setAttribute("name", e.getKey());
		field.appendChild(doc.createTextNode(e.getValue()));
	    }

	    TransformerFactory transformerFactory = TransformerFactory.newInstance();
	    Transformer transformer = transformerFactory.newTransformer();
	    transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no");

	    DOMSource source = new DOMSource(doc);
	    StreamResult result = new StreamResult(out);

	    transformer.transform(source, result);

	} catch (ParserConfigurationException | TransformerException e) {
	    logger.error("Error saving XML", e);
	}

	out.println();
	if (close) out.close();
    }