[Home] [By Thread] [By Date] [Recent Entries]
Hi Yves,
You did not show how the output should really look like. But I suppose "inside a <b> container" means a <b> element with children <b1>, <b2> etc. Here's what I came up with, which does not involve grouping, but instead uses mode-switching. If you have textual content in your real input, you may need some changes, because I neglect the default template below. Output of below stylesheet on your input: <a>
<b>
<b1/>
<b2/>
</b>
<c/>
</a>
<a>
<b>
<b2/>
</b>
<c/>
</a>The Stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes" /> <xsl:template match="/"> <xsl:apply-templates select="$abc/*" /> </xsl:template> <xsl:template match="*[starts-with(name(), 'b')][1]"> <b> <xsl:apply-templates select="self::* | following-sibling::*" mode="b"/> </b> </xsl:template> <xsl:template match="*[starts-with(name(), 'b')]" mode="b"> <xsl:copy> <xsl:apply-templates select="node() | @*" mode="#current"/> </xsl:copy> </xsl:template> <!-- copy all others --> <xsl:template match="*[not(starts-with(name(), 'b'))]"> <xsl:copy> <xsl:apply-templates select="node() | @*" /> </xsl:copy> </xsl:template> </xsl:stylesheet> Cheers, -- Abel Braaksma http://www.nuntia.nl Yves Forkl wrote: Given two XML fragments
|

Cart



