Re: [xsl] Seeking a smarter tokenize for augmented text

Subject: Re: [xsl] Seeking a smarter tokenize for augmented text
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 7 May 2021 10:11:53 -0000
Am 06.05.2021 um 11:09 schrieb Trevor Nicholls trevor@xxxxxxxxxxxxxxxxxx:
> I would like to extend this so that it can handle an element
> consisting of text lines with some embedded markup (there won't be
> much, but there will be some). For example, taking:
> <textlines>this is line <seq>1</seq>
> this is <var>line</var> 2
> this <emph>is</emph> line 3</textlines>
> and producing
> <textlines>
> <line>this is line <seq>1</seq></line>
> <line>this is <var>line</var> 2</line>
> <line>this <emph>is</emph> line 3</line>
> </textlines>

That part could be done with

<xsl:stylesheet xmlns:xsl="";

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

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

   <xsl:template match="textlines">
           <xsl:variable name="transformed-textlines">
               <xsl:apply-templates mode="insert-markers"/>
           <xsl:for-each-group select="$transformed-textlines/node()"
                   <xsl:apply-templates select="current-group()"/>

   <xsl:template mode="insert-markers" match="text()">
       <xsl:analyze-string select="." regex="\n+">
               <xsl:value-of select="."/>

   <xsl:template match="lb"/>


Current Thread