In javascript, trying to transform a dynamically created XML data island, sorting it using a XSL file, but the result is the sorted data all on one line, without XML formatting or proper indenting. It looks like the is not being used at all. I need the XML tags and indenting to be generated in the resulting transformNode().
javascript code:
var sourceXML = document.getElementById(XMLViewID); //textArea containing XML
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(sourceXML.value);
var xslDoc = new ActiveXObject("Microsoft.XMLDOM");
xslDoc.async=false;
xslDoc.load("xsl.xsl");
// This should be the sorted, formatted XML data, in tree and indented format?
var sorted = xmlDoc.transformNode(xslDoc);
XML DATA:
<table>
<row>
<A>j</A>
<B>0</B>
</row>
<row>
<A>c</A>
<B>4</B>
</row>
<row>
<A>f</A>
<B>6</B>
</row>
</table>
xsl.xsl:
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
<xsl:template match="/">
<xsl:apply-templates select="table/row">
<xsl:sort select="A" order="ascending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="row">
<xsl:value-of select="A"/>
<xsl:value-of select="B"/>
</xsl:template>
I assume with 'indent=yes' and 'omit-xml-declaration=no' that the resulting transformation should be with indenting and formatting:
<?xml version="1.0" encoding="UTF-16"?>
<table>
<row>
<tr>
<A>j</A>
<B>0</B>
</tr>
<tr>
<A>c</A>
<B>4</B>
</tr>
<tr>
<A>f</A>
<B>6</B>
</tr>
</row>
</table>
But instead it is: c4f6j0 in one line, no formatting, no XML tags...