[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Seeking a smarter tokenize for augmented text

Subject: Re: Seeking a smarter tokenize for augmented text
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 6 May 2021 09:28:57 -0000
Re:  Seeking a smarter tokenize for augmented text
There seem to be two broad strategies for this kind of problem:

(a) process the text nodes to insert "markup" structure, e.g. replace newlines
by <nl/>, and then process as nodes, e.g. using for-each group-starting="nl".

(b) process the embedded elements converting them to text, e.g. convert
<var>line</var> to %line%, then process as text, then reconstitute the
markup.

For this example, (a) seems easier.

Michael Kay
Saxonica

> On 6 May 2021, at 10:09, Trevor Nicholls trevor@xxxxxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi
>
> Turning xml like this:
>
> <textlines>this is line 1
> this is line 2
> this is line 3</textlines>
>
> into something like this:
>
> <textlines>
> <line>this is line 1</line>
> <line>this is line 2</line>
> <line>this is line 3</line>
> </textlines>
>
> is simple and I have functions that do it. But they rely on <textlines>
being an xs:string, which is processed by a trivial function I wrote:
>
> <xsl:function name="my:intoLines" as="xs:string*">
>   <xsl:param name="arg" as="xs:string?" />
>   <xsl:sequence select="tokenize( $arg, '(\r\n?|\n\r?)' )" />
> </xsl:function>
>
> 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>
>
> Sequence and tokenize isn't adequate but is there a way to do this that
won't overtax my brain too much?
>
> cheers
> T
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.