[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Find/replace algorithm
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@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Thursday, March 25, 2021 12:29 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: 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@xxxxxxxxxxxx<mailto:mike@xxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx rytech.com>> Sent: Wednesday, March 24, 2021 7:48 PM To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx>> Subject: Re: 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/unsu b/xsl-list/612310__;!!A4F2R9G_pg!OjZv4pOytV-MHnnYzmpZEWsTCp9w_XI7Yyg96PzhL59t Gen5qlBh1A78_VDXguo9h6eSCQiTqAhIqMA$> (by email) XSL-List info and archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__ ;!!A4F2R9G_pg!OjZv4pOytV-MHnnYzmpZEWsTCp9w_XI7Yyg96PzhL59tGen5qlBh1A78_VDXguo 9h6eSCQiTRK-dOrQ$> EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu b/xsl-list/3380743__;!!A4F2R9G_pg!OjZv4pOytV-MHnnYzmpZEWsTCp9w_XI7Yyg96PzhL59 tGen5qlBh1A78_VDXguo9h6eSCQiTgWCRb9c$> (by email<>)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|