XSLT indent not working with MSXML



I am trying to "pretty" an XML file. As suggested in some other SO questions, I am using the following stylesheet to transform:



<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output indent="yes" method="xml" encoding="UTF-16" />
<xsl:strip-space elements="*"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


However this is not producing the desired results. For an input file of:



<A><B><C /></B></A>


the generated output is:



<?xml version="1.0" encoding="UTF-16"?>
<A>
<B>
<C>
</C>
</B>
</A>


But the output I am expecting is (header line doesn't matter):



<A>
<B>
<C />
</B>
</A>


So there are two problems:



  • There is no indentation in the output

  • The <C /> tag has been "unpacked", which I don't want.


I have tried with MSXSL.exe , and by using (via C++) IXMLDOMDocument2::transformNode outputting to a BSTR, both methods produce identical output.


What's going wrong here?


No comments:

Post a Comment