Subject: Re: [xsl] Wrap changing element sequence into container: with 'for-each-group'? From: Yves Forkl <Y.Forkl@xxxxxx> Date: Tue, 30 Jan 2007 18:13:30 +0100 |
What I am having trouble to do is adding a container around a specific
(fixed-order) sequence of those 'p' elements, say, 'p[style="a"]' and 'p[style="b"]', where the first of these may not always occur.
If you can identify a comparison between two adjacent siblings which, if true, means that they go in different containers, then you can use group-starting-with. For example, in this case the condition might be that the element is not immediately preceded by an element with a value for @style that is alphabetically less than the current element's @style:
group-starting-with="p[not(preceding-sibling::p[1][@style lt current()/@style])]"
> <xsl:template match="*[starts-with(name(), 'b')][1]"> > <container> > <xsl:apply-templates > select="self::* | following-sibling::*" > mode="within_container"/> > </container> > </xsl:template> > > <xsl:template match="*[starts-with(name(), 'b')]" > mode="within_container"> > <xsl:copy> > <xsl:apply-templates select="node() | @*" > mode="#current"/> > </xsl:copy> > </xsl:template> > > <xsl:template match="*[not(starts-with(name(), 'b'))]"> > <xsl:copy> > <xsl:apply-templates select="node() | @*" /> > </xsl:copy> > </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Wrap changing element seq, Michael Kay | Thread | Re: [xsl] Wrap changing element seq, David Carlisle |
Re: [xsl] Dynamic, configurable tra, Yves Forkl | Date | Re: [xsl] Storing XML doc refs in v, David Carlisle |
Month |