xsl-list
[Top] [All Lists]

[xsl] mixed content grouping by whitespace

2010-04-11 11:38:36
Hi there,

I've been playing with some mixed content grouping by whitespace.  I
have an input like:

====
<ab xmlns="http://www.tei-c.org/ns/1.0";>
    <seg>foo blort wibble</seg><lb/>
    <seg>foo-<m>blort</m> wibble</seg><lb/>
    <seg><w>foo</w>-<m>blort</m> wibble</seg><lb/>
</ab>
====

and what I want as an output is to group any whitespace separated bits
of content with <w> elements, including existed child <w> and <m>

====
<ab xmlns="http://www.tei-c.org/ns/1.0";>
    <seg><w>foo</w> <w>blort</w> <w>wibble</w></seg><lb/>
    <seg><w>foo-<m>blort</m></w> <w>wibble</w></seg><lb/>
    <seg><w><w>foo</w>-<m>blort</
m></w> <w>wibble</w></seg><lb/>
</ab>
====

Currently I'm doing something like:
====
<xsl:for-each-group select="tei:m|tei:w|text()" group-starting-with="text()">
        <w>
        <xsl:apply-templates select="current-group()"/>
        </w>
    </xsl:for-each-group>
====

Which, as one would expect does things like
<w><w>foo</w></w><w>-<m>blort</m></w> when I would want
<w><w>foo</w>-<m>blort</m></w>.  This, of course, completely
understandable since that is what I'm asking it to do by
group-starting-with="text()".

Suggestions?

-James

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--