Many, many solutions. This one use fine grained traversal:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()[1]|@*"/>
</xsl:copy>
<xsl:apply-templates select="following-sibling::node()[1]"/>
</xsl:template>
<xsl:template match="bar">
<foo>
<xsl:call-template name="identity"/>
</foo>
<xsl:apply-templates select="following-sibling::bar[1]"/>
</xsl:template>
<xsl:template match="qux">
<xsl:copy>
<xsl:apply-templates select="node()[1]|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Output:
<root>
<foo>
<bar>bar 1</bar>
<baz>baz 1</baz>
<qux>qux 1</qux>
</foo>
<foo>
<bar>bar 2</bar>
<baz>baz 2</baz>
<qux>qux 2</qux>
</foo>
</root>
Other solution: push style with key.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="kElementByPrecedingBar" match="root/*[not(self::bar)]"
use="generate-id(preceding-sibling::bar[1])"/>
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="bar" mode="wrap">
<foo>
<xsl:apply-templates select=".|key('kElementByPrecedingBar',
generate-id())"/>
</foo>
</xsl:template>
<xsl:template match="root">
<xsl:copy>
<xsl:apply-templates select="bar" mode="wrap"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>