Hi, Actually, you can. By setting standalone option:
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); The original patch checks before adding a newline after the processing-instruction (xml-header) that there's at least indenting on, AND that there's either DOCTYPE or standalone set as well. If these are true, it adds newline. However, there's a bug I'd say, since it won't affect other processing-instructions, if you add one more and DOCTYPE, you will get something nasty: <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <?xml-stylesheet href="Finvoice.xsl" type="text/xsl"?><!DOCTYPE Finvoice SYSTEM "Finvoice.dtd"> <Finvoice Version="1.2"> Now, some mainframes have XML-libraries, which can only read one tag per line. How can I add newline after <?xml-stylesheet?> ? Has anyone found a way? At the moment, all these are rejected by the mainframe due to validation error, and so long, nothing goes through. In my opinion, indenting should mean line-change after every element / processing-instruction / etc, but apparently this is not the way Xalan is designed. Can anyone at least point out where processing-instructions are added, so I could modify Xalan to my own needs (if these changes aren't accepted to head) ? I upgraded from Xalan 2.0.4 (!) to newer one, and while it had double-newline bug, this one has no-newline bug. So many wonderful options.. - Micke -----Original Message----- However when I plug-in Xalan 2.7.1 I get a result file: <?xml version="1.0" encoding="UTF-8"?><doc> <para>foo bar</para> </doc> Is there a way to make the document element appear on a new line after the XML declaration when using the indent="yes" output option?