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

Re: Best way to handle multiple string replacements?

Subject: Re: Best way to handle multiple string replacements?
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Tue, 06 Jun 2000 15:32:48 +0100
multiple string table
Sebastian,

At 01:40 PM 6/6/00 +0100, Sebastian Rahtz wrote:
>I am full of admiration for Jeni's ingenuity, but I wonder whether a
>simpler approach might not be to build  a lookup table of character
>positions and their expansions (using XSL keys), and then cycle over
>the text letter by letter seeing if there is a replacement?

I'm not sure that I understand the method your proposing.  Do you mean to
have:

<foo:characters>_%${}&amp;</foo:characters>

defining the characters to be escaped, and then index into them using
substring()?  That would work just as well for those characters, but how
would you do the string replacements?  If you have the time, could you put
together the (pseudo)code to elucidate your method?

>If you work by cycling through the replacements, surely
>
><foo:char>$</foo:char>
>and
><foo:replace>$\mathbb{P}$</foo:replace>
>
>will fight? the $ in the second fragment might end up escaped

Not so - the replacements are done in order, and the same order each time
(so it is predictable).  As in Warren's original example, all the
single-character escaping is done first (by the replace_characters
template), and all the string replacements are done second (by the
replace_strings template).

Cheers,

Jeni

Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email
jeni.tennison@xxxxxxxxxxxxxxxx



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.