The XSLT XML output format is stripping the whitespace before the closing tag
<Import Include="System.Web" /> becomes <Import Include="System.Web"/>
As the XSLT is also removing many nodes in the documents it's applied to, I would like to strip whitespace except in the case of the closing slash.
The xslt is being applied to many xml ms proj files
template.xsl;
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="http://schemas.microsoft.com/developer/msbuild/2003">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <!--<xsl:preserve-space elements="text"/>-->
    <xsl:template match='@*|node()'>
        <xsl:copy>
            <xsl:apply-templates select='@*|node()'/>
        </xsl:copy>
    </xsl:template>
    ... 
    ...
</xsl:stylesheet>
                This is a serialization detail that is impossible to control from XSLT.
Any reliable way to achieve it would be to run a post-processor on the result of the transformation.
I ended up using gnuwin32 sed to add a space (note the ^> : ^ is required to escape the angled bracket)
sed\sed.exe -i "s/\"\/^>/\" \/>/g" %outfile%
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With