|
Subject: [xsl] Merging like Siblings within a variable as="element()*" From: Alex Muir <alex.g.muir@xxxxxxxxx> Date: Fri, 20 Aug 2010 14:57:20 +0000 |
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?
Thanks Much
Alex
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Why do the namespace appe, Hermann Stamm-Wilbra | Thread | Re: [xsl] Merging like Siblings wit, Martin Honnen |
| RE: [xsl] Why do the namespace appe, Fabien Tillier | Date | Re: [xsl] Merging like Siblings wit, Martin Honnen |
| Month |