title: XSLT stylesheet replaces self-closing tags with empty paired tags
body: <p>I'm using XSLT to process my ASP.Net web.config file to insert some extra log4net configuration.  It's applied by the NANT standard task called <code>&lt;style&gt;</code>.  While it successfully inserts the new content, it turns the many self-closing tags into empty paired tags.  For example, a partial web.config looks like this before:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"&gt;
  &lt;configSections&gt;
      &lt;section name="log4net"
               type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/&gt;
  &lt;/configSections&gt;
  &lt;appSettings&gt;
      &lt;add key="SomeKey" value="SomeValue"/&gt;
  &lt;/appSettings&gt;
  </code></pre>
  
  <p>After applying the stylesheet, the <code>&lt;section&gt;</code> and <code>&lt;add&gt;</code> tags (and all other tags) are no longer self-closing:</p>
  
  <pre><code>&lt;configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"&gt;
      &lt;configSections&gt;
          &lt;section name="log4net"
           type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"&gt;
          &lt;/section&gt;
      &lt;/configSections&gt;
      &lt;appSettings&gt;
          &lt;add key="SomeKey" value="SomeValue"&gt;
          &lt;/add&gt;
      &lt;/appSettings&gt;
  </code></pre>
  
  <p>My stylesheet looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!-- This stylesheet is applied to web.config files to insert log4net appender
  filters that will prevent logging messages resulting from pages requested by
  AIS monitoring systems. --&gt;
  &lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
      exclude-result-prefixes="msxsl"&gt;
      &lt;xsl:output method="xml" indent="yes" /&gt;
      &lt;xsl:preserve-space elements="configuration"/&gt;
      &lt;!-- Copy input to output, most of the time --&gt;
      &lt;xsl:template match="@* | node()"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select="@* | node()" /&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
  
      &lt;!-- Within log4net &lt;appender&gt; elements, insert standard filters to
      exclude logging traffic resulting from AIS monitoring.  Any existing
      filters are preserved. --&gt;
      &lt;xsl:template match="/configuration/log4net/appender"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select="@* | node()" /&gt;
              &lt;xsl:comment
              &gt; Filters inserted by build server during deployment &lt;/xsl:comment&gt;
              &lt;filter name="AIS monitor"
               type="log4net.Filter.PropertyFilter"&gt;
                  &lt;regexToMatch value="^35\.8\.113\.[0-9]+$"/&gt;
                  &lt;key value="ClientIP"/&gt;
                  &lt;acceptOnMatch value="false"/&gt;
              &lt;/filter&gt;
              &lt;filter name="AIS load balancer"
               type="log4net.Filter.PropertyFilter"&gt;
                  &lt;regexToMatch value="^10\.160\.0\.[0-9]+$" /&gt;
                  &lt;key value="ClientIP"/&gt;
                  &lt;acceptOnMatch value="false"/&gt;
              &lt;/filter&gt;
              &lt;filter name="localhost" type="log4net.Filter.PropertyFilter"&gt;
                  &lt;stringToMatch value="127.0.0.1"/&gt;
                  &lt;key value="ClientIP"/&gt;
                  &lt;acceptOnMatch value="false"/&gt;
              &lt;/filter&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Before using NANT to process the stylesheet, I tried MSBuild, using the MSBuild Extension Pack task <code>XmlTask</code>.  It preserved the self-closing tags, but would lose most of the line breaks, which made the file human-unreadable (though otherwise correct).  Using NANT fits in nicely with my build process, so I'd prefer to use it if I can.</p>
  
  <p>It seems like I should be able to specify that I want to keep self-closing tags in the stylesheet, but I can't figure out how.</p>