title: Turn doxygen xml into valid and semantic rich HTML
body: <p>Consider this code generated by Doxygen:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;detaileddescription&gt;
    &lt;para&gt;This function fills buffer with the content of $param_inline(template_string) by applying to the following rules:&lt;/para&gt;
    &lt;para&gt;
      &lt;itemizedlist&gt;
        &lt;listitem&gt;
          &lt;para&gt;Any number less than the number of elements in $param_inline(strings) following a % in reffers to an index in $param_inline(strings).&lt;/para&gt;
        &lt;/listitem&gt;
        &lt;listitem&gt;
          &lt;para&gt;Any symbol following a % that is not a valid decimal digit will be prited as it is.&lt;/para&gt;
        &lt;/listitem&gt;
        &lt;listitem&gt;
          &lt;para&gt;If the resulting string including NULCHAR is longer than $param_inline(buffer_length), the string is truncated.&lt;/para&gt;
        &lt;/listitem&gt;
        &lt;listitem&gt;
          &lt;para&gt;If a number following a % cannot be converted, or the number is larger than or equal to the number of elements in $param_inline(strings), the function returns.&lt;/para&gt;
        &lt;/listitem&gt;
        &lt;listitem&gt;
          &lt;para&gt;In any case, buffer is terminated with a NULCHAR.&lt;/para&gt;
        &lt;/listitem&gt;
      &lt;/itemizedlist&gt;
    &lt;/para&gt;
    &lt;para&gt;
      &lt;simplesect kind="return"&gt;
        &lt;para&gt;Non-zero if the function succeeded, zero otherwise.&lt;/para&gt;
      &lt;/simplesect&gt;
    &lt;/para&gt;
  &lt;/detaileddescription&gt;
  </code></pre>
  
  <p>Using xslt, I want to turn this into clean HTML like this</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt;This function ...&lt;/p&gt;
  &lt;ul&gt;
       &lt;li&gt;&lt;p&gt;Any number ...&lt;/p&gt;&lt;/li&gt;
       &lt;li&gt;&lt;p&gt;Any symbol ...&lt;/p&gt;&lt;/li&gt;
       ...
  &lt;/ul&gt;
  &lt;p class="return"&gt;Non-zero if ...&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The problem is that Doxygen likes to enclose lists inside paragraphs or sections inside paragraphs.</p>
  
  <p>I currently have this to match <code>para</code>:</p>
  
  <pre><code>&lt;xsl:template match="para"&gt;
  &lt;p&gt;
  &lt;xsl:apply-templates select="./*[not(self::simplesect|self::parameterlist |self::itemizedlist|self::orderedlist)] | text()"/&gt;
  &lt;/p&gt;
  &lt;xsl:for-each select="./*"&gt;
       &lt;xsl:apply-templates select="." /&gt;
  &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>It sort of works, but it generates empty <code>p</code> tags.</p>