- <if test="not(@class='continuation') or not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:div or self::html:li)]">
- <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
- <copy>
- <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
- <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+ <if test="not(processing-instruction()[local-name()='LesML-Continuation']) or not(preceding-sibling::node()[position()=1 and self::html:* and contains(' div li h1 h2 h3 h4 h5 h6 ', local-name())])">
+ <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+ <choose>
+ <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
+ <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+ <element name="hgroup" namespace="&xhtml;">
+ <apply-templates select="node()" mode="LesML:finalize-tree"/>
+ <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
+ <choose>
+ <when test="self::html:div">
+ <apply-templates select="node()" mode="LesML:finalize-tree"/>
+ </when>
+ <otherwise>
+ <copy>
+ <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+ </copy>
+ </otherwise>
+ </choose>
+ </for-each>
+ </element>
+ </when>
+ <when test="not(processing-instruction()[local-name()='LesML-Continuation'])">
+ <copy>
+ <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+ <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+ <apply-templates select="node()" mode="LesML:finalize-tree"/>
+ </for-each>
+ </copy>
+ </when>
+ <otherwise>