Re: [xsl] Breaking paragraphs one linebreaks

Subject: Re: [xsl] Breaking paragraphs one linebreaks
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 May 2019 15:01:06 -0000
On 09.05.2019 15:44, Manuel Souto Pico terminolator@xxxxxxxxx wrote:

Do you think I can use XSLT to do this more or less easily?

Yes, XSLT 3 can do it easily, using tokenize to split the segments and then grouping to group the different segments together:

<xsl:stylesheet xmlns:xsl="";

<xsl:mode on-no-match="shallow-copy"/>

<xsl:output indent="yes"/>

<xsl:param name="lb" as="xs:string">&lt;br&gt;</xsl:param>

  <xsl:template match="tu">
      <xsl:variable name="split">
          <xsl:apply-templates mode="split"/>
      <xsl:for-each-group select="$split/tuv/seg" group-by="position()
mod count($split/tuv[1]/seg)">
          <tu tuid="{position()}">
              <xsl:apply-templates select="current-group()/snapshot()/.."/>

<xsl:mode name="split" on-no-match="shallow-copy"/>

  <xsl:template match="seg" expand-text="yes" mode="split">
      <xsl:for-each select="tokenize(., '(' || $lb || ')+')">


Current Thread