Since it seems this 'HTML' document is, in fact, a well-formed XML document, something like that could do the trick if there is no element between the li elements :
Code:
<xsl:template match="li">
<xsl:choose>
<xsl:when test="name(ancestor::*[1])!='ul'">
<xsl:if test="not(preceding-sibling::li)">
[list]
<xsl:for-each select=". | following-sibling::li">
<li><xsl:apply-templates/></li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<li><xsl:apply-templates/></li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>