Subject: Re: [xsl] Combining consecutive siblings From: "andrew welch" <andrew.j.welch@xxxxxxxxx> Date: Tue, 13 Jun 2006 10:47:25 +0100 |
Hi Andrew
Thank you very much. Just a few concluding notes:
1. ---- <xsl:template match="CELL"> <td><xsl:apply-templates select="SB"/></td> </xsl:template> ----
I know my example didn't show it, but in Real Life there are an awful lot of things in CELLs, and every so often amongst them there is a run of SB elements which I want to collapse in this way. So the above is too simple, unfortunately. (There also may be two runs of SB with some other intervening element, as well.)
<xsl:template match="CELL"> <td><xsl:apply-templates/></td> </xsl:template>
...for the very reason that youv'e found - you want to apply-templates to all elements, and just do nothing <SB> elements that arent the first in a sequence of <SB> elements as they will be processed by a moded template.
2. ---- <xsl:template match="SB[preceding-sibling::*[1][self::SB]]" priority="2"/> ----
This I have added - it should kick in for any SB selected (without a mode) whether or not 'select="SB"' was specified on the apply-templates node, right?
3. When I experimented by interspersing random elements amongst the SB runs, I found that they were each appearing twice. I see now, I think, that Dr Kay's templates presumed that the "higher-order" template was only selecting the first <B> child, hence the need to include ---- <xsl:apply-templates select="following-sibling::*[not(self::b)][1]"/> ---- (or [not(self::SB)] in my case) after the closing <B> in the main template. As my "higher-order" template (I don't know what the canonical term is, sorry) is simply doing a general <apply-templates /> then non-SB children are pulled in anyway. So I dropped that line as well.
Correct, you don't need that line if the template matching the parent element has called apply-templates. You would need that line if the parent called apply-templates on the first element only, and then each template would call apply-templates on the appropriate following-sibling. Its just two different ways of walking the tree.
On the samples I have tried since making these changes, it seems now to be doing what I want.
cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Combining consecutive sib, Trevor Nicholls | Thread | RE: [xsl] Combining consecutive sib, Michael Kay |
RE: [xsl] Combining consecutive sib, Trevor Nicholls | Date | RE: [xsl] Combining consecutive sib, Michael Kay |
Month |