Search code examples
coldfusionwddx

Coldfusion wddx with indentation


I want to store my localization files in wddx format.

The problem is that sometimes I need to edit translation manually which might be a problem with wddx format as Coldfusion saves it in file as a single line.

Is there a way for me to format wddx string before saving it?

Leonti


Solution

  • I don't think ColdFusion natively supports indenting xml/wddx. So either you can use xmlindent from cflib.org or if you are comfortable with java there are many solutions available see this thread like

    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    // indent and omit xml declaration
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    StreamResult result = new StreamResult(new StringWriter());
    DOMSource source = new DOMSource(doc);
    transformer.transform(source, result);
    return result.getWriter().toString();