[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Wrap changing element sequence into container: with 'for-each-group'?


Subject: RE: [xsl] Wrap changing element sequence into container: with 'for-each-group'?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 30 Jan 2007 14:31:04 -0000

> What I am having trouble to do is adding a container around a specific
> (fixed-order) sequence of those `p4 elements, say,
> `p[style="a"]4 and `p[style="b"]4, where the first of these
> may not always occur.

I suspect you're giving an example rather than an exact specification, so
any solution you are given might not work.

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])]"

If that's not the case, then you'll have to tell us what the precise
specification of the problem is. There are of course some cases where you
will have to resort to sibling recursion.

Michael Kay
http://www.saxonica.com/


Current Thread