[xsl] Merging elements

Subject: [xsl] Merging elements
From: Nic Gibson <nicg@xxxxxxxxxx>
Date: Thu, 27 Oct 2011 10:13:34 +0200
Morning all

I have a problem that I'm having trouble thinking of an elegant solution for.
I have xhtml files which contain spans which need to be merged. The files are
an intermediate stage in a pipeline converting from docx to xhtml (the stage
before working out the sectional structure and converting formatting to
headings). The spans may or may not be separated by whitespace. Something
like;

<p><span class="strong-emphasis">Fome</span> <span
class="strong-emphasis">Zero</span>
        <span class="strong">: la stratigie du Brisil pour risoudre les
problhmes de l'insicuriti alimentaire et de la faim </span></p>

And also:

<p><span class="strong">C</span><span class="strong">ontexte</span></p>

I need to merge those spans with identical class attribute values along with
the whitespace to get something like:

<p><span class="strong-emphasis">Fome Zero</span>
        <span class="strong">: la stratigie du Brisil pour risoudre les
problhmes de l'insicuriti alimentaire et de la faim </span></p>

And:

<p><span class="strong">Contexte</span></p>

I've been looking at the problem for too long and have a horribly complex set
of grouping statements that applied in a multiple mode stylesheet. I'm
convinced that there's a simpler way to do this but I think that I can't see
the wood for the trees. Does anyone have an elegant way to do this?

thanks

nic
--
Corbas Consulting
Digital Publishing Consultancy and Training
http://www.corbas.co.uk, +44 (0)7718 906817/+44 (0)1273 930765

Current Thread