Subject: Re: Best way to handle multiple string replacements? From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx> Date: Tue, 06 Jun 2000 15:32:48 +0100 |
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>_%${}&</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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Best way to handle multiple str, Sebastian Rahtz | Thread | Re: Best way to handle multiple str, Sebastian Rahtz |
Is Xalan C++ really that slow?, Mack, Daniel | Date | Re: Standalone Attributes?, Henning Behme |
Month |