[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Joining sibling elements
Tempore 19:49:30, die 08/10/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Marcin MiEkowski <milek_pl@xxxxx>:
<b>this</b><b> </b><b>is</b><b> </b><b>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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|