Re: [xsl] Grouping by character runs (and keeping element structure)

Subject: Re: [xsl] Grouping by character runs (and keeping element structure)
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 31 Jul 2006 14:33:26 -0400
Christian,

At 06:34 AM 7/27/2006, you wrote:
Continuing my grouping issues:

XSLT2 handles grouping on a node level quite conveniently. However,
adding structure to legacy, rather flat content (i.e.: character runs)
still poses challenges in grouping....

[Fabulous examples snipped, until]


A worst-case scenario of course would be:

__ EXAMPLE 3 __

<p><ul><b>Note</b> <i>#4</i>: Don't tumble dry your pet</ul>.</p>

TASK:
Group the leading paragraph text "Note #4:" including any contained
markup using <marker> to a child of <p> so that the result looks like:

<p><marker><ul><b>Note</b> <i>#4</i>:</ul></marker>
   <ul>Don't tumble dry your pet</ul>.</p>

SOLUTION:
Same problems as in EXAMPLE 2, but additionally note that the <ul>
element must be split/duplicated so that <marker> can be a child of <p>,
yet retains the full formatting info in form of the contained element
structure.

Is there a certain pattern on how to tackle these kind of problems in
XSLT, or is the language just not the tool of choice for this kind of
transformation?

My preference would be to go all the way up before going down again. Thus my first transform would target the arrangement


<note no="4">Don't tumble-dry your pet.</note>

... from which any of your targets could be created.

This may not always be possible; but my guess is that where it isn't, you already have more serious problems.

Cheers,
Wendell

Current Thread