Linefeed in XML

When I generate an XML file there are no linefeeds between the elements. The receiving party requires these linefeeds. Is this a known issue? If so, is there a way I can enforce the linefeeds? UPDATE: For those interested, the following code adds linefeeds and indents to the XML. Input is FileDocument: Node document = null; boolean keepDeclaration = true; InputStream is = Core.getFileDocumentContent(this.getContext(), xmlDocument.getMendixObject()); StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); is.close(); String xml = writer.toString(); try { document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes())).getDocumentElement(); keepDeclaration = xml.startsWith("<?xml"); } catch (Exception e) { throw new MendixRuntimeException("Unable to beautify file", e); } String newXML; try { DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); LSSerializer lsWriter = impl.createLSSerializer(); lsWriter.getDomConfig().setParameter("format-pretty-print", true); // Set this to true if the output needs to be beautified. lsWriter.getDomConfig().setParameter("xml-declaration", keepDeclaration); // Set this to true if the declaration is needed to be outputted. newXML = lsWriter.writeToString(document); InputStream istr = new ByteArrayInputStream(newXML.getBytes()); Core.storeFileDocumentContent(this.getContext(), xmlDocument.getMendixObject(), istr); } catch (Exception e) { throw new MendixRuntimeException("Unable to beautify file", e); } return true;
1 answers

There is no way to do this except by generating XML manually in a Java action. I recommend talking to the receiving party, as linefeeds are not in the XML specification and shouldn't be required.