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

Re: Usage of XSLT in the field of text replacement.

Subject: Re: Usage of XSLT in the field of text replacement.
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Thu, 9 Oct 2008 21:26:05 +0530
Re:  Usage of XSLT in the field of text replacement.
Hi Ken,
  Thanks for your nice analysis of my solution. Please see my answers
below to some of your points.

On Thu, Oct 9, 2008 at 5:42 PM, G. Ken Holman
<gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
> I think, Mukul, the original poster should be aware that with your proposed
> solution the "temp.ini" file must express the "old" string value as a
> regular expression and not a simple string.

You are right. I think the OP thinks, that old string values are
simple strings to be taken in their lexical form, and not as regular
expressions. I hope the OP will clarify this.

> If there are sensitive regular expression characters in those values the results may not be > as desired.

You are right. My solution assumed that the old strings should be
regular expressions. For the example posted by the OP, I had to escape
the [ & ] characters. Escaping all possible escape characters could be
tedious with my solution.

> Then again, the original poster may want the power of regular expressions in
> the control file, in which case what you have presented is almost complete,

As suggested by you, the OP could consider having old string values as
regular expressions. Then he can reuse most of the code I posted.

> For example, had you used replace() instead of analyze string the original poster would
> get access to "$" in the replacement string.

The semantics of function, 'replace' is:
replace(string? $input, string $pattern, string $replacement) -> string?

I thought that using 'replace' function was not suitable (with one
call for a single string to be analyzed) because, the replacement
string cannot vary for each different delimiter. Somehow we need to
index in a map like structure to find the replacement string. I have
done this in my solution.

> There are so many possible ways to approach the solution based on what the
> original poster wanted that I felt his request was unclear.

You are correct. Actually, my intention to post this solution was to
showcase, that XSLT 2.0 is capable enough to solve this kind of
problem and we can use a facility like, xsl:analyze-string.

I did not intend to write some code, that the OP can use out of the
box. He has to finalize certain constraints, and think some ideas of
his own too.

> But if you just look on the face of it, then I think the strings in "temp.ini" are not
> expected to be regular expressions, in which case the use of either
> <xsl:analyze-string> or replace() would be out of place for fear of
> unexpected results.

Your analysis is correct, I feel ...

I hope the OP will get back to the list, with his analysis of the
solution I posted, and further queries if any.

Mukul Gandhi

Current Thread


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.
First Name
Last Name
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.