On 11.04.2010 19:43, David Carlisle wrote:
> On 11/04/2010 17:37, James Cummings wrote:
> group-starting-with="text()">
>
>
> probably that wants to be text()[not(normalize-space(.))]
>
> David
Couldn't get the desired result like that.
I applied a two-step process:
1. Mark up whitespace using intermediate <seg @type="sep"> </seg>;
2. group adjacent WS (and non-WS) nodes, put the non-WS groups in a
newly created w element.
==========8<------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0"
exclude-result-prefixes="xs tei"
>
<xsl:output method="xml" />
<xsl:template match="tei:seg" >
<xsl:copy>
<xsl:variable name="sep">
<xsl:apply-templates mode="sep" />
</xsl:variable>
<xsl:for-each-group select="$sep/node()"
group-adjacent="boolean(self::tei:seg[(_at_)type='sep'])">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<xsl:value-of select="current-group()" />
</xsl:when>
<xsl:otherwise>
<w xmlns="http://www.tei-c.org/ns/1.0">
<xsl:apply-templates select="current-group()"/>
</w>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
<xsl:template match="tei:seg/text()" mode="sep">
<xsl:analyze-string select="." regex="\s+">
<xsl:matching-substring>
<seg type="sep" xmlns="http://www.tei-c.org/ns/1.0">
<xsl:value-of select="."/>
</seg>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template match="@* | *" mode="#all">
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="#current"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
==========8<------------------------
Gerrit
--~------------------------------------------------------------------
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>
--~--