Dieses Sheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()[1]"/>
</xsl:copy>
<xsl:apply-templates select="following-sibling::node()[1]"/>
</xsl:template>
<xsl:template match="para">
<xsl:copy>
<xsl:apply-templates select="@*|node()[1]"/>
</xsl:copy>
<xsl:apply-templates select="link" mode="copy"/>
<xsl:apply-templates select="following-sibling::node()[1]"/>
</xsl:template>
<xsl:template match="para/link"/>
<xsl:template match="para/link" mode="copy">
<xsl:copy>
<xsl:apply-templates select="@*|node()[1]"/>
</xsl:copy>
<para>
<xsl:apply-templates select="following-sibling::node()[1]"/>
</para>
</xsl:template>
</xsl:stylesheet>
Ausgang:
<para>Lorem ipsum </para><link>dolor</link><para> sit amet</para>
Hinweis: Feinkörnige Traversal.
bearbeiten: Compact Code:
<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="self::para/link" mode="copy"/>
<xsl:apply-templates select="following-sibling::node()[1]"/>
</xsl:template>
<xsl:template match="para/link"/>
<xsl:template match="para/link" mode="copy">
<xsl:call-template name="identity"/>
</xsl:template>
<xsl:template match="node()[preceding-sibling::node()[1]
/self::link/parent::para]">
<para>
<xsl:call-template name="identity"/>
</para>
</xsl:template>
</xsl:stylesheet>
Gute Frage, +1. Siehe meine Antwort für eine vollständige und sehr kurze/einfache Lösung. :) –