Я хочу разделить этот узел на <foo>
:
<p>
<span>This is before foo.</span>
<foo>inside foo</foo>
<span>This is after foo.</span>
</p>
Я хочу получить результат
<p>
<span>This is before foo.</span>
</p>
<foo>inside foo</foo>
<p>
<span>This is after foo.</span>
</p>
Но я получаю
<p>
<span>This is before foo.</span>
<p>
<span>This is before foo.</span>
</p>
<foo>inside foo</foo>
<p>
<span>This is after foo.</span>
</p>
<span>This is after foo.</span>
</p>
И вот таблица стилей, которую я пытаюсь использовать:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="p/foo">
<xsl:element name="p">
<xsl:apply-templates select="preceding-sibling::node()"/>
</xsl:element>
<foo>
<xsl:apply-templates/>
</foo>
<xsl:element name="p">
<xsl:apply-templates select="following-sibling::node()"/>
</xsl:element>
</xsl:template>
</xsl:transform>
Как мне избавиться от этого дополнительного вывода?
Редактировать: Дать более реалистичный пример c. См http://xsltransform.net/pNP88xQ/2