The predominance of newlines and tabs works if xsl:output="text"
in Firefox and Chrome. Oddly enough, IE ignores text mode indentation. The following is an example stylesheet with a link that demonstrates this:
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="newline-indent.xml"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="" > <xsl:output method="text" encoding="utf-8" version="1.0" media-type="text/plain" indent="yes" standalone="no" omit-xml-declaration="no"/> <xsl:template xml:space="preserve" match="/"> <root> <child>1 </child> <child> <grandchild>	 1.1 </grandchild> </child> <child> <grandchild> <great-grandchild>	 	 1.1.1</great-grandchild> </grandchild> </child> </root> </xsl:template> </xsl:stylesheet>
The following comment from Mozilla's Error explains why XML serialization does not work for the XML namespace:
The current version of Gecko uses an XML serializer to serialize XHTML content.
Use style
tags and literals in tags to format output in IE:
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="newline-indent-ie.xml"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="" > <xsl:output method="xml" encoding="utf-8" version="1.0" media-type="application/xml" indent="yes" standalone="no" omit-xml-declaration="no"/> <xsl:template match="/"> <style>* { white-space:pre-wrap; }</style> <root> <child >1</child> <child> <grandchild >1.1</grandchild> </child> <child> <grandchild> <great-grandchild >1.1.1</great-grandchild> </grandchild> </child> </root> </xsl:template> </xsl:stylesheet>
References
source share