する
<xsl:template match="p[following-sibling::*[1][self::element]]//text() | element[preceding-sibling::*[1][self::p]//text()">
<xsl:value-of select="normalize-space()"/>
</xsl:template>
あなたがしたいことをしますか?
<xsl:template match="element"><xsl:apply-templates/></xsl:template>
とにかく組み込みのテンプレートがそれを行うので、必要はありません。
コードをテストする時間を見つけました。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="p[following-sibling::*[1][self::element]]//text() |
element[preceding-sibling::*[1][self::p]]//text()">
<xsl:value-of select="normalize-space()"/>
</xsl:template>
<xsl:template match="text()[preceding-sibling::*[1][self::p] and following-sibling::*[1][self::element] and not(normalize-space())]">
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
変形する
<body>
<p>
some text here
</p>
<element>
some more text
</element>
</body>
の中へ
some text here some more text