Мое предложение будет сводиться к
<xsl:template match="body">
<div class="panel-body">
<xsl:for-each-group select="*" group-starting-with="pb">
<div class="test" style="width: 49%;border:solid 1px red; float:left">
<xsl:apply-templates select="current-group()"/>
</div>
</xsl:for-each-group>
</div>
</xsl:template>
<xsl:template match="pb">
<div class="page number" style="text-align:right;">
<xsl:text>[F.</xsl:text>
<xsl:value-of select="@n"/>
<xsl:text>]</xsl:text>
<hr/>
</div>
</xsl:template>
<xsl:template match="p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
"Полный пример":
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="#all"
version="3.0">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:output method="html" indent="yes" html-version="5"/>
<xsl:template match="/">
<html>
<head>
<title>.NET XSLT Fiddle Example</title>
</head>
<body>
<xsl:apply-templates select="//body"/>
</body>
</html>
</xsl:template>
<xsl:template match="body">
<div class="panel-body">
<xsl:for-each-group select="*" group-starting-with="pb">
<div class="test" style="width: 49%;border:solid 1px red; float:left">
<xsl:apply-templates select="current-group()"/>
</div>
</xsl:for-each-group>
</div>
</xsl:template>
<xsl:template match="pb">
<div class="page number" style="text-align:right;">
<xsl:text>[F.</xsl:text>
<xsl:value-of select="@n"/>
<xsl:text>]</xsl:text>
<hr/>
</div>
</xsl:template>
<xsl:template match="p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
</xsl:stylesheet>
https://xsltfiddle.liberty -development.net / ncntCSc
Для процессора XSLT 2 вам нужно будет указать <xsl:mode on-no-match="shallow-copy"/>
в качестве шаблона идентификации
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
С этим кодом преобразуется фрагмент
<body>
<pb></pb>
<p> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. </p>
<pb></pb>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. </p>
</body>
входного сэмплак фрагменту HTML
<div class="panel-body">
<div class="test" style="width: 49%;border:solid 1px red; float:left">
<div class="page number" style="text-align:right;">[F.]
<hr>
</div>
<p> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et
accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
</div>
<div class="test" style="width: 49%;border:solid 1px red; float:left">
<div class="page number" style="text-align:right;">[F.]
<hr>
</div>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et
accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
</div>
</div>