我想将文本分成几个部分:
源 XML:
<data>
<p>hello</p>
<p>nice</p>
<p>BREAK</p>
<p>world</p>
</data>
我的半成功尝试:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
<xsl:output indent="yes"/>
<xsl:template match="data">
<xsl:for-each-group select="p" group-starting-with=".[. = 'BREAK']">
<chapter>
<xsl:copy-of select="current-group()"/>
</chapter>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
我想得到的结果(片段):
<chapter>
<p>hello</p>
<p>nice</p>
</chapter>
<chapter>
<p>world</p>
</chapter>
相反,我得到
<chapter>
<p>hello</p>
<p>nice</p>
</chapter>
<chapter>
<p>BREAK</p>
<p>world</p>
</chapter>
(它仍然包含<p>BREAK</p>
)
我的问题是:有没有一种直接的方法来摆脱<p>BREAK</p>
元素?