Subject: Re: [xsl] Merging like Siblings within a variable as="element()*" From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Fri, 20 Aug 2010 17:07:22 +0200 |
Hi,
I've been using the following code that works based on templates to merge <chunk> siblings beside one another such that the following
<chunk>1</chunk> <chunk>2</chunk> <notChunk>3</notChunk> <chunk>4</chunk> <chunk>5</chunk>
would be merged to
<chunk>12</chunk> <notChunk>3</notChunk> <chunk>45</chunk>
Here is the code: <xsl:template match="chunk" priority="1"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:copy-of select="text()"/> <xsl:apply-templates select="following-sibling::*[1][self::chunk]" mode="more"/> </xsl:copy> </xsl:template>
<xsl:template match="chunk[preceding-sibling::*[1][self::chunk]]" priority="2"/>
<xsl:template match="chunk" mode="more"> <xsl:copy-of select="text()"/> <xsl:apply-templates select="following-sibling::*[1][self::chunk]" mode="more"/> </xsl:template>
This works great if I'm applying the templates to an xml file however I'm interested to have the chunks within a <xsl:variable name="content" as="element()*> and then merge them and output them and I'm not sure how to go about merging the like siblings within a variable.
Any suggestions are highly appreciated?
Martin Honnen http://msmvps.com/blogs/martin_honnen/
<- Previous | Index | Next -> |
---|---|---|
[xsl] Merging like Siblings within , Alex Muir | Thread | Re: [xsl] Merging like Siblings wit, Alex Muir |
[xsl] Merging like Siblings within , Alex Muir | Date | Re: [xsl] check for whitespace valu, Wendell Piez |
Month |