[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] mixed content grouping by whitespace


Subject: [xsl] mixed content grouping by whitespace
From: James Cummings <james+xsl@xxxxxxxxxxxxxxxxx>
Date: Sun, 11 Apr 2010 17:37:52 +0100

Hi there,

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

====
<ab xmlns="http://www.tei-c.org/ns/1.0">
B B B  <seg>foo blort wibble</seg><lb/>
B B B  <seg>foo-<m>blort</m> wibble</seg><lb/>
B B B  <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">
B B B  <seg><w>foo</w> <w>blort</w> <w>wibble</w></seg><lb/>
B B B  <seg><w>foo-<m>blort</m></w> <w>wibble</w></seg><lb/>
B B B  <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()">
B B B B B B B  <w>
B B B B B B B  <xsl:apply-templates select="current-group()"/>
B B B B B B B  </w>
B B B  </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>.B  This, of course, completely
understandable since that is what I'm asking it to do by
group-starting-with="text()".

Suggestions?

-James


Current Thread