The XSLT code provided below is not producing the desired indentation in the output of XML when I am using Firefox but it is working fine for chrome.
Here is the code:
var sourceXml = '<Environment name=“DEFAULT”>\n<ADFConnections>\n<Connection name="MapViewer”>\n<Attribute name="url”>\n</Connection>\n</ADFConnections>\n</Environment>'
var xmlDoc = new DOMParser().parseFromString(sourceXml, 'application/xml');
var xsltDoc = new DOMParser().parseFromString([
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',
' <xsl:output indent="yes"/>',
' <xsl:strip-space elements="*"/>',
' <xsl:template match="node()|@*">',
' <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>',
' </xsl:template>',
'</xsl:stylesheet>',
].join('\n'), 'application/xml');
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDoc);
var resultDoc = xsltProcessor.transformToDocument(xmlDoc);
var resultXml = new XMLSerializer().serializeToString(resultDoc);
In FireFox, it was showing like in single line
<Environment name="DEFAULT"><ADFConnections><Connection name="MapViewer”> .....
without any indentation. What I was doing wrong here where as it is working as expected in chrome with indentation.
To show you how you can use XSLT 3 with SaxonJS 2 and control the serialization in a cross-browser compatible way (note that the input XML you posted didn't seem to be well-formed XML so I corrected it a bit):