Tempore 19:49:30, die 08/10/2005 AD, hinc in
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Marcin Miłkowski
<milek_pl(_at_)o2(_dot_)pl>:
<b>this</b><b> </b><b>is</b><b> </b><b>bold<text</b>
which should be transformed this:
<b>this is bold text</b>
Here's a stylesheet that will handle this simple scenario:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="*[name(preceding-sibling::node()[1])=name()]"/>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
<xsl:call-template name="mergeSiblings"/>
</xsl:copy>
</xsl:template>
<xsl:template name="mergeSiblings">
<xsl:for-each select="following-sibling::node()[1][name()=name(current())]">
<xsl:apply-templates/>
<xsl:call-template name="mergeSiblings"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The more complex case can be solved with this algorithm in multiple passes.
regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Vincit omnia simplicitas
Keep it simple
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--