This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:key name="kFollowing" match="list"
use="generate-id(preceding-sibling::para[1])"/>
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
<xsl:variable name="vFol"
select="key('kFollowing',generate-id())"/>
<xsl:if test="$vFol">
<ol>
<xsl:apply-templates mode="copy"
select="key('kFollowing',generate-id())"/>
</ol>
</xsl:if>
</xsl:template>
<xsl:template match="list" mode="copy">
<li><xsl:value-of select="."/></li>
</xsl:template>
<xsl:template match="list"/>
</xsl:stylesheet>
when applied on the following XML document (wrapping the provided input in a single top element):
<t>
<para>blah blah</para>
<list>num1</list>
<list>num2</list>
<list>num3</list>
<para>blah blah</para>
<list>num1</list>
<list>num2</list>
<para>blah blah blah blah blah</para>
</t>
produces the wanted, correct result:
<t>
<p>blah blah</p>
<ol>
<li>num1</li>
<li>num2</li>
<li>num3</li>
</ol>
<p>blah blah</p>
<ol>
<li>num1</li>
<li>num2</li>
</ol>
<p>blah blah blah blah blah</p>
</t>
UPDATE: The OP has indicated in a comment that now he wants a solution where any non-list
element can delimit a group of adjacent list
siblings.
Here is the solution to the changed question :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="kFollowing" match="list"
use="generate-id(preceding-sibling::*[not(self::list)][1])"/>
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(self::list) and following-sibling::*[1][self::list]]">
<xsl:call-template name="identity"/>
<xsl:variable name="vFol"
select="key('kFollowing',generate-id())"/>
<xsl:if test="$vFol">
<ol>
<xsl:apply-templates mode="copy"
select="key('kFollowing',generate-id())"/>
</ol>
</xsl:if>
</xsl:template>
<xsl:template match="list" mode="copy">
<li><xsl:value-of select="."/></li>
</xsl:template>
<xsl:template match="list"/>
</xsl:stylesheet>
When this transformation is applied on the following XML document (Note that the separating elements have now random names):
<t>
<bara>blah blah</bara>
<list>num1</list>
<list>num2</list>
<list>num3</list>
<vara>blah blah</vara>
<list>num1</list>
<list>num2</list>
<dara>blah blah blah blah blah</dara>
</t>
the wanted, correct result is produced:
<t>
<bara>blah blah</bara>
<ol>
<li>num1</li>
<li>num2</li>
<li>num3</li>
</ol>
<vara>blah blah</vara>
<ol>
<li>num1</li>
<li>num2</li>
</ol>
<dara>blah blah blah blah blah</dara>
</t>