[Home] [By Thread] [By Date] [Recent Entries]
Dear Gabor,
I suggest a two-pass process: first replace whitespace with an empty separator element, then group (either starting with the separator or adjecent non-separator nodes). See below. -Gerrit <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" version="2.0" exclude-result-prefixes="saxon xs" > <xsl:output
method="xml"
indent="yes"
saxon:suppress-indentation="seg"
/> <xsl:template match="@* | *" mode="#all">
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="#current"/>
</xsl:copy>
</xsl:template><xsl:template match="p"> <xsl:copy> <xsl:variable name="separated" as="node()*"> <xsl:apply-templates mode="insert-sep" /> </xsl:variable> <xsl:for-each-group select="$separated" group-adjacent="not(self::sep)"> <xsl:if test="current-grouping-key()"> <seg> <xsl:sequence select="current-group() except self::sep" /> </seg> </xsl:if> </xsl:for-each-group> <!-- Alternative grouping, may create empty seg though: <xsl:for-each-group select="$separated" group-starting-with="sep"> <seg> <xsl:sequence select="current-group() except self::sep" /> </seg> </xsl:for-each-group> --> </xsl:copy> </xsl:template> <xsl:template match="text()" mode="insert-sep">
<xsl:analyze-string select="." regex="\s+">
<xsl:matching-substring>
<sep/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="." />
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template></xsl:stylesheet> On 09.09.2010 10:29, Gabor Tsth wrote: Dear All,
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler ---------------------------------------------------------------------- Besuchen Sie uns auf der Frankfurter Buchmesse in Halle 4.2, Stand G446. Mehr dazu unter www.le-tex.de/de/buchmesse.html
|

Cart



