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: Yves Forkl <Y.Forkl@xxxxxx>
Date: Tue, 30 Jan 2007 14:54:43 +0100
Hi List,

thank you for your help, David and Abel. While the two suggestions you
proposed are elegant solutions, my problem has changed meanwhile. :-)
That is, I did not explain it correctly.

My context is as follows: I have a series of `pB4 elements which should
be treated differently according to their `styleB4 attribute. Rather than
defining a set of push style templates with `match="p[style='value1']"B4,
I prefer to call, for each `pB4, a named template acting as general
dispatcher, which will call one out of a set of action-specific named
templates. Each style is assigned to exactly one type of action.

What I am having trouble to do is adding a container around a specific
(fixed-order) sequence of those `pB4 elements, say, `p[style="a"]B4 and
`p[style="b"]B4, where the first of these may not always occur. However,
 the processing of `p[style="b"]B4, and more particularly the necessity
of creating a container at that moment, varies with the presence of
`p[style="a"]B4. I came up with two alternative, but similar ideas:

1) "Tell" the template in charge of `p[style="b"]B4 about the fact
whether the container has already been added when processing `p[style="a"]B4.

2) When processing `p[style="a"]B4, hold execution of the container
creation by putting it on a kind of stack that is shared with
`p[style="b"]B4. Only when processing the latter we create the container,
after deleting it from the stack, if necessary.

Does that make sense to you? If so, which way can I go to implement it?
(Tunnel parameters?) Or can you think of other approaches that might be
preferable?

Yves

Current Thread