[xsl] regrouping split elements

Subject: [xsl] regrouping split elements
From: James Cummings <james@xxxxxxxxxxxxxxxxx>
Date: Mon, 21 Dec 2009 17:01:14 +0000
Hi there,

I'm trying to up-scale some bibliographic output converted with a
docxtotei stylesheet and then tidy it up somewhat.  The problem is
that the output seems to randomly break in the middle of words.  So
the current output I have is:

<div>
    <p>
        <hi rend="bold">Dibdin</hi>
        <hi rend="bold">, Thomas Jo</hi>
        <hi rend="bold">hn</hi>
    </p>
    <p>
        <hi rend="italic">The </hi>
        <hi rend="italic">widow and the w</hi>
        <hi rend="italic">ill</hi>, published as <hi
rend="italic">Four legs and two l</hi>
        <hi rend="italic">egs</hi>
        <hi rend="italic">.</hi>
    </p>
    <p>1826</p>
<!-- and many more -->
</div>

and obviously I want it more to be something like:


<div>
    <p>
        <hi rend="bold">Dibdin, Thomas John</hi>
    </p>
    <p>
        <hi rend="italic">The widow and the will</hi>, published as
<hi rend="italic">Four legs and two legs.</hi>
    </p>
    <p>1826</p>
<!-- and many more -->
</div>

(and you can guess that I'm going to change anything in bold to be
authors and anything in italics to be a title...then group them into
individual entries.)

But to get this first step done, I've started out a number of
different ways before hitting stumbling blocks with
previous/following-sibling.  Is the right approach (in XSLT2) instead
to do something like xsl:for-each-group on the value of hi/@rend
inside each 'p'?

Any thoughts appreciated,
-James

Current Thread