Hi Rick,
I'm a noob so this may not be the best answer. For free-form regsubs that
aren't on word boundaries, maybe you could pass your sequence of <entry> nodes
to an XSLT function, then that function applies the first <entry> and calls
itself with the remainder? Then you could use this function to apply all
substitutions from a suitable template.
Of course, this is brute force and inefficient. But I don't know how else to
handle an arbitrary list of free-form regsubs. I suspect that the cost to
pre-screen for a match is the same as the cost to attempt the substitution.
* Chris
From: rick(_at_)rickquatro(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, March 25, 2021 12:29 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Find/replace algorithm
Thank you Michael. I like the idea of keeping the processing cost constant but
I was going to use regular expressions in my map, so I may still have to loop
through the lookup structure.
From: Michael Kay
mike(_at_)saxonica(_dot_)com<mailto:mike(_at_)saxonica(_dot_)com>
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com<mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>>
Sent: Wednesday, March 24, 2021 7:48 PM
To: xsl-list
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com<mailto:xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>>
Subject: Re: [xsl] Find/replace algorithm
My instinct would be
(a) build a map containing the replacements
(b) for each text node, tokenize the content, then scan the tokens looking each
one up in the map.
The big advantage of this approach is that the cost is constant regardless how
many substitutions there are, whereas most other approaches have a cost that
increases linearly with the number of substitutions.
Michael Kay
Saxonica
EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsub/xsl-list/612310__;!!A4F2R9G_pg!OjZv4pOytV-MHnnYzmpZEWsTCp9w_XI7Yyg96PzhL59tGen5qlBh1A78_VDXguo9h6eSCQiTqAhIqMA$>
(by email)
XSL-List info and
archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__;!!A4F2R9G_pg!OjZv4pOytV-MHnnYzmpZEWsTCp9w_XI7Yyg96PzhL59tGen5qlBh1A78_VDXguo9h6eSCQiTRK-dOrQ$>
EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsub/xsl-list/3380743__;!!A4F2R9G_pg!OjZv4pOytV-MHnnYzmpZEWsTCp9w_XI7Yyg96PzhL59tGen5qlBh1A78_VDXguo9h6eSCQiTgWCRb9c$>
(by email<>)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--